1

I am trying to use condas to install an environment that uses python 2.7 and numpy version 1.10

I try to create such an environment

 conda create -n test2 python=2.7 numpy=1.10

It contends it is going to install the software I specified

The following NEW packages will be INSTALLED:

mkl:        11.3.3-0     
numpy:      1.10.4-py27_2
openssl:    1.0.2l-0     
pip:        9.0.1-py27_1 
python:     2.7.13-0     
readline:   6.2-2        
setuptools: 27.2.0-py27_0
sqlite:     3.13.0-0     
tk:         8.5.18-0     
wheel:      0.29.0-py27_0
zlib:       1.2.8-3

and then activate it and run python

 source activate test2
 python

it informs me I am using python version 2.7.13 and then I try check the numpy version number

 import numpy
 numpy.version.version

It tells me I have version

'1.13.0'

which is not the version I specified. On the other hand, If I skip specifying the python version, it installs python 3, but the correct version of numpy (1.10.4)

Any ideas about what is going on here? Furthermore, how do I fix this? Thanks!

Edit: as per Uvar's comment

 conda create -n test4 python=2.7 numpy=1.10 --no-deps

Tells me

The following NEW packages will be INSTALLED:

numpy:  1.10.4-py27_2
python: 2.7.13-0

but then if I source activate test4 and check the numpy version number, it tells me I am running 1.13.0 again.

Edit 2 (Again in response to a query by Uvar):

 conda list -n test2

returns

# packages in environment at /home/ohnoplus/anaconda3/envs/test2:

#

 mkl                       11.3.3                        0   
 numpy                     1.10.4                   py27_2   
 openssl                   1.0.2l                        0 
 pip                       9.0.1                    py27_1   
 python                    2.7.13                        0   
 readline                  6.2                           2   
 setuptools                27.2.0                   py27_0   
 sqlite                    3.13.0                        0   
 tk                        8.5.18                        0   
 wheel                     0.29.0                   py27_0   
 zlib                      1.2.8                         3

Edit 3: If I source activate test2 and then inside of python import numpy and numpy.__file__ I get the following

'/home/ohnoplus/.local/lib/python2.7/site-packages/numpy/__init__.pyc'

meanwhile if outside of python, but inside of test2, I echo $PATH

I get

/home/ohnoplus/anaconda3/envs/test2/bin:/home/ohnoplus/anaconda3/bin:/home/ohnoplus/bin:/home/ohnoplus/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Edit 4: @Uvar and @MSeifert point out that I should get my path variables pointing in the right place. I'll experiment with getting this right but I have a couple of questions:

I notice that the python sys.path in test2 appears to be looking in the right place for numpy if I look at sys.paths

 import sys
 print (sys.path)

['', '/home/ohnoplus/anaconda3/envs/test2/lib/python27.zip', '/home/ohnoplus/anaconda3/envs/test2/lib/python2.7', '/home/ohnoplus/anaconda3/envs/test2/lib/python2.7/plat-linux2', '/home/ohnoplus/anaconda3/envs/test2/lib/python2.7/lib-tk', '/home/ohnoplus/anaconda3/envs/test2/lib/python2.7/lib-old', '/home/ohnoplus/anaconda3/envs/test2/lib/python2.7/lib-dynload', '/home/ohnoplus/.local/lib/python2.7/site-packages', '/home/ohnoplus/anaconda3/envs/test2/lib/python2.7/site-packages', '/home/ohnoplus/anaconda3/envs/test2/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg']

Should I be updating $PATH in as referenced in the command line, this sys.path variable, or something else?

14
  • Are you running source activate or source activate test2? If you are running the former, you're switching to the root env and not the one you just created. Commented Aug 9, 2017 at 17:40
  • Sorry. That was a mis-type on stackoverflow. I ran source activate test2 on my system to get the behavior described. Commented Aug 9, 2017 at 17:45
  • 1
    Could you check numpy.__file__ and compare it to the path for your test? environment. Commented Aug 9, 2017 at 19:33
  • 1
    Any conda environment (except the root one) has an envs folder somewhere in the filepath. From what I see you don't use the Python/NumPy from your conda installation. The good news is: The solution is simple. The bad news is: You have to restructure your PATH. :) Commented Aug 9, 2017 at 19:49
  • 1
    So, the package is installed correctly, but seems to me that once you go into the interpreter, you get hooked up with your root install instead of the environment. I am unfortunately no expert on this. You will need to change your PATH or do something which you are better off not doing: unbinding the link between python and python2 .. it IS working in a python 3 install, since then python in your activated environment silently points to python3 .. Srry to be of little help :( Commented Aug 9, 2017 at 19:51

1 Answer 1

1

Ok. Got it! When I run sys.path it looks in ".local/lib/python2.7/site-packages" before it looks in "anaconda3/envs/test2/lib/python2.7/site-packages"

I don't think I was ever using the python version in .local, and so I just moved the python2.7 directory out of ~/.local/lib. This seemed to remedy the problem. Now when I import numpy, the version is as expected.

Reference: The discussion linked below, along with the comments of Uvar and MSeifert, pointed me in the direction to solve this problem.

https://github.com/conda/conda/issues/448

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.