# Python version mismatch in install?

**URL:** <https://openmc.discourse.group/t/python-version-mismatch-in-install/299>\
**Category:** User Support\
**Created:** [November 16, 2017, 9:04pm UTC](https://openmc.discourse.group/t/python-version-mismatch-in-install/299 "2017-11-16T21:04:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gridley](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/gridley/32/1064_2.png) [@gridley](https://openmc.discourse.group/u/gridley)\
**Post date:** [November 16, 2017, 9:04pm UTC](https://openmc.discourse.group/t/python-version-mismatch-in-install/299/1 "2017-11-16T21:04:36Z")

</div>

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/](https://pypi.python.org/simple/ipython/)  
Downloading [https://pypi.python.org/packages/fa/50/974211502bd72873728d44c3013fe79875c819c8fb69f778bcfd67bc7d38/ipython-6.2.1.tar.gz#md5=6873d91d340c6069a4f7c2d65258523b](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:

> <https://github.com/ipython/ipython/blob/master/README.rst>

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?

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [November 17, 2017, 12:05am UTC](https://openmc.discourse.group/t/python-version-mismatch-in-install/299/2 "2017-11-17T00:05:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gridley](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/gridley/32/1064_2.png) [@gridley](https://openmc.discourse.group/u/gridley)\
**Post date:** [November 17, 2017, 2:06am UTC](https://openmc.discourse.group/t/python-version-mismatch-in-install/299/3 "2017-11-17T02:06:18Z")

</div>

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

`

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [November 17, 2017, 1:37pm UTC](https://openmc.discourse.group/t/python-version-mismatch-in-install/299/4 "2017-11-17T13:37:09Z")

</div>

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](https://docs.python.org/3/library/venv.html) module) or using a distribution like [Anaconda](https://www.anaconda.com/download). 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

---

<div class="post-metadata">

**Author:** ![gridley](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/gridley/32/1064_2.png) [@gridley](https://openmc.discourse.group/u/gridley)\
**Post date:** [November 18, 2017, 7:48pm UTC](https://openmc.discourse.group/t/python-version-mismatch-in-install/299/5 "2017-11-18T19:48:04Z")

</div>

Paul,

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

Thanks again!
