Author Topic: Error trying to initialize script  (Read 1464 times)

Atemporal

  • Newbie
  • *
  • Posts: 4
Error trying to initialize script
« on: November 06, 2017, 05:30:29 AM »
When I try to run a script--either via the ovitos command or the gui interface--I get an error
ModuleNotFoundError: No module named 'numpy'
ERROR: Failed to initialize Python interpreter.

I do have numpy installed (via conda), and doesn't ovito come with a version of it anyway?

What I wanted to do was just display two types of particles at once, spheres and spherocyllinders, but the gui will only let me do one or the other, not a mixture. Is there a better way to do this?

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: Error trying to initialize script
« Reply #1 on: November 06, 2017, 08:22:03 AM »
Please let me know which version of OVITO and operating system you are using.

Yes, the binary program packages from the OVITO website (should) come with Numpy included.

I haven't tested how well it works, but OVITO should display spherocylindrical particles with zero length as simple spheres. So I am wondering: Can't you just set the 'Aspherical Shape.Z' property of these particles to zero? (Using the Compute Property modifier, for example)

If that doesn't work, it might be necessary to import the entire dataset into OVITO a second time. Select "Add to scene" when importing a second time. You can choose different particle display styles for the two datasets. It might be necessary to delete mutually exclusive subsets of particles from each dataset as you don't want to display the same particles twice.

Atemporal

  • Newbie
  • *
  • Posts: 4
Re: Error trying to initialize script
« Reply #2 on: November 06, 2017, 11:33:09 PM »
To give a little more context: I'm trying to display the .gsd output of a HOOMD-Blue simulation, and it should be as you described, all particles are sphereocyllinders, but some have zero length (spheres). I'm running Ovito 2.9.0 on Ubuntu, the gui interface loads, but any attempts to invoke scripting immediately fails with the numpy not found error, so I can't manually edit particle properties.

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: Error trying to initialize script
« Reply #3 on: November 07, 2017, 10:29:06 AM »
Let me know if you manage to get the mixed display of spherocylindrical and spherical particles working or not. I will consider your feedback in the future design of OVITO. Maybe it is possible to make this process somewhat easier.

Regarding your Python problem:

I assume you are running the binary Ovito 2.9.0 package from the website, right? (If you would run your own local build of Ovito 2.9.0, it would make a difference, because only the official version ships with a packaged Python interpreter + Numpy module).

I am still trying to find an explanation why the Numpy module isn't found on your system. Maybe you can check your PYTHONPATH encironment variable to see if there are any conflicting entries. Here is how it looks on my Ubuntu machine:

Code: [Select]
stuko@mogli9:~/progs/ovito-2.9.0-x86_64$ echo ${PYTHONPATH}
/nfshome/stuko/programme/scitools-0.6/lib/

By running ovitos, I can check which paths are searched for modules (This might not work for you if initialization fails early):

Code: [Select]
stuko@mogli9:~/progs/ovito-2.9.0-x86_64$ bin/ovitos
This is OVITO's interactive IPython interpreter. Use quit() or Ctrl-D to exit.
In [1]: import sys
In [2]: sys.path
Out[2]:
['',
 '/nfshome/stuko/progs/ovito-2.9.0-x86_64/bin/../lib/ovito/plugins/python',
 '/nfshome/stuko/progs/ovito-2.9.0-x86_64/lib/python3.5/site-packages/numpy-1.11.2-py3.5-linux-x86_64.egg',
 '/nfshome/stuko/programme/scitools-0.6/lib',
 '/nfshome/stuko/progs/ovito-2.9.0-x86_64/lib/python35.zip',
 '/nfshome/stuko/progs/ovito-2.9.0-x86_64/lib/python3.5',
 '/nfshome/stuko/progs/ovito-2.9.0-x86_64/lib/python3.5/plat-linux',
 '/nfshome/stuko/progs/ovito-2.9.0-x86_64/lib/python3.5/lib-dynload',
 '/nfshome/stuko/.local/lib/python3.5/site-packages',
 '/nfshome/stuko/progs/ovito-2.9.0-x86_64/lib/python3.5/site-packages',
 '/nfshome/stuko/progs/ovito-2.9.0-x86_64/lib/python3.5/site-packages/IPython/extensions',
 '/nfshome/stuko/.ipython']

Atemporal

  • Newbie
  • *
  • Posts: 4
Re: Error trying to initialize script
« Reply #4 on: November 07, 2017, 05:22:59 PM »
I can't do anything with ovitos, it fails when it tries to load __init__.py, nothing else happens.

Trying echo ${PYTHONPATH} just returns a blank line. Could it be because my python build is installed through conda? Or should that not matter because of the internals of ovito?

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: Error trying to initialize script
« Reply #5 on: November 07, 2017, 08:38:33 PM »
Have you tried the current development version already (Ovito 3.0.0)? Maybe it works better than the older 2.9 release.

I'm still thinking about reasons why there could be a conflict between Conda and OVITO. OVITO comes with a complete, self-contained CPython interpreter, which is extracted together with the program files from the .tar.gz archive that you downloaded from the website. This interpreter includes its own library of standard Python modules and extensions such as Numpy. I would say the only way another Python interpreter on the system (e.g. conda) could interfere with OVITO's interpreter is via environment variables. Maybe you can check if there are any other variables set (besides PYTHONPATH), which are relevant for a CPython interpreter.

Atemporal

  • Newbie
  • *
  • Posts: 4
Re: Error trying to initialize script
« Reply #6 on: November 08, 2017, 04:50:49 AM »
I figured it out!

I had installed my build of ovito via

$ sudo apt-get install ovito

which added ovito and ovitos as commands, which was convenient. However, for some reason this appears to break the ovitos initialization. I discovered when trying to upgrade to 3.0.0 that installing it from the .tar.gz file works. I tried it with 2.9.0, and it also works. Something about the apt-get installation is breaking the numpy installation.

Now to figure out how to do what I was trying to do originally...

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: Error trying to initialize script
« Reply #7 on: November 08, 2017, 09:33:16 AM »
Ah, okay, that explains it.

I didn't realize you had installed the Ubuntu package "ovito", which comes from the Debian package repository. I cannot provide any support for this package. There is an independent maintainer responsible for it, who I am not affiliated with. (Bugs like the one you encountered should be reported to that Debian package maintainer.) As 'upstream' developer of OVITO I provide my own installation packages on www.ovito.org, and only those come with a separate Python interpreter.

Now that you downloaded one of these binary packages, you are good to go. Let me know if you have any further questions.
« Last Edit: November 08, 2017, 09:39:57 AM by Alexander Stukowski »