Forum Navigation
You need to log in to create posts and topics.

Problem with revoking libraries from Ovito's scripting interface

I import libraries, like matplotlib, numpy etc. and I cannot use their attributes in a python script.

I added them in the folder lib. Although, when I'm trying to use their classes, for example, the pyplot of matplotlib, I get this error message:

cannot import name 'pyplot' from 'matplotlib' (unknown location).

What is the correct place of installing these libraries, so that I can use their attributes?

Hi,

To answer this question, I first need to know which Python interpreter you are using to execute your scripts.

OVITO Pro has an embedded Python interpreter, which is used for executing scripts within the graphical user interface. The same interpreter is accessible through the ovitos executable that is included in any OVITO Pro package available on our website. If you want to make third-party Python packages available in this integrated interpreter, you should install them by running ovitos -m pip install <package_name>. Just copying files into the lib folder is probably wrong.

On the other hand, if you are using an external Python interpreter (CPython from http://www.python.org), then you probably have installed the OVITO Python module in this interpreter by running pip install ovito. In this case, your script should automatically have access to any other Python package installed in the same interpreter.

The third possibility is that your are using an Anaconda environment, and you have installed our ovito Anaconda package to make the OVITO Python module available in Anaconda's Python interpreter. Then, again, third-party Python packages should be importable if you have installed them using the conda install command.

-Alex

Hi Alex,

thanks a lot for your reply!

I use the python interpreter that is accessible through the ovitos executable. I tried to use the command that you suggested (ovitos -m pip install pandas), but it didn't work. I get the following error message:

ovitos: command not found

-Nikos

You probably have to specify the full path to the ovitos executable (ovitos.exe on Windows) in order to run it. Where did you install OVITO Pro? And are you on Windows, Linux, or macOS?

Yeah, that's true. I had to specify the full path. Thanks a lot Alex!

新的OVITO微信频道!
New for our users in China: OVITO on WeChat 

Official OVITO WeChat channel operated by Foshan Diesi Technology Co., Ltd.