Python version mismatch in install?

Hi all,

I’m trying to get openMC running to easily deal with cross section data in a Jupyter notebook. I’d like to build from source rather than get code from the PPA. Hopefully everything will be using python3 on my Ubuntu 16.10 computer, but it appears something tries to use python 2.7:

`

Installed /usr/local/lib/python2.7/site-packages/openmc-0.9.0-py2.7.egg
Processing dependencies for openmc==0.9.0
Searching for ipython
Reading https://pypi.python.org/simple/ipython/
Downloading https://pypi.python.org/packages/fa/50/974211502bd72873728d44c3013fe79875c819c8fb69f778bcfd67bc7d38/ipython-6.2.1.tar.gz#md5=6873d91d340c6069a4f7c2d65258523b
Best match: ipython 6.2.1
Processing ipython-6.2.1.tar.gz
Writing /tmp/easy_install-ZBslmg/ipython-6.2.1/setup.cfg
Running ipython-6.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ZBslmg/ipython-6.2.1/egg-dist-tmp-apiu7d

IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Beginning with IPython 6.0, Python 3.3 and above is required.

See IPython README.rst file for more information:

Python sys.version_info(major=2, minor=7, micro=13, releaselevel=‘final’, serial=0) detected.

error: Setup script exited with 1

`

Where looking at the sys.version line reveals that 2.7 gets used at some point, which my Ipython 6.1 cannot use.

Can anyone help me set up the install to use the system-included python3, which is version 3.5?

Hi Gavin,

The problem probably has to do with which Python interpreter CMake finds when it runs. I believe you can hardwire it with the following:

cmake -DPYTHON_EXECUTABLE=python3 …

Give that a try and let us know if it works out.

Best regards,
Paul

Hey Paul,

Thanks, this seems to have immediately done the trick in terms of no error messages arriving. Unfortunately, after running with “cmake …/openmc -DPYTHON_EXECUTABLE=python3”, I receive the error message:

`

[gavin][~/code/openmc-build]> make test
Running tests…
Test project /home/gavin/code/openmc-build
Start 1: test_asymmetric_lattice.py
Could not find executable /home/gavin/code/openmc-build/python3

`

Moreover, attempting to use openmc after “sudo make install” gives

`

[gavin][~/code/openmc]> which openmc
/usr/local/bin/openmc
[gavin][~/code/openmc]> openmc
openmc: error while loading shared libraries: libopenmc.so: cannot open shared object file: No such file or directory

`

Hi Gavin,

For the first issue, perhaps try using an absolute path, i.e., -DPYTHON_EXECUTABLE=/usr/bin/python3 and see if that helps. For the second issue, try adding the directory containing libopenmc.so (in your case, most likely /usr/local/lib/) to your LD_LIBRARY_PATH environment variable.

Another thing you may want to consider, and that I would generally recommend, is to use a virtual environment, either through Python itself (the venv module) or using a distribution like Anaconda. Anaconda has its own version of virtual environments (conda environments). When you use a virtual environment, ‘which python’ will show the Python interpreter that is installed as part of that environment, so when cmake is run there will be no confusion. The problem in your case is that in Ubuntu, /usr/bin/python is actually Python 2, not Python 3.

Hope this helps!

Best,
Paul

Paul,

Thanks, this seems to have done the trick. OpenMC seems to be working fine now.

Thanks again!