conda python没有使用numpy版本,如果我还指定它应该使用python 2,我会尝试安装 [英] conda python isn't using the numpy version I try install if I also specify that it should use python 2

查看:296
本文介绍了conda python没有使用numpy版本,如果我还指定它应该使用python 2,我会尝试安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用condas安装使用python 2.7和numpy版本1.10的环境

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

我尝试创建这样的环境

 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

然后激活它并运行python

and then activate it and run python

 source activate test2
 python

它通知我我正在使用python版本2.7.13,然后尝试检查numpy版本号

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

它告诉我我有版本

'1.13.0'

'1.13.0'

这不是我指定的版本.另一方面,如果我跳过指定python版本,它将安装python 3,但安装了正确版本的numpy(1.10.4)

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!

根据Uvar的评论

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

告诉我

将安装以下新软件包:

The following NEW packages will be INSTALLED:

numpy:  1.10.4-py27_2
python: 2.7.13-0

但是如果我source activate test4并检查numpy版本号,它会告诉我我再次运行1.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.

编辑2(再次响应Uvar的查询):

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

 conda list -n test2

返回

/home/ohnoplus/anaconda3/envs/test2中的环境中的#个软件包:

# 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

如果我source activate test2然后在python import numpynumpy.__file__内部,则得到以下内容

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'

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

同时,如果在python之外,但在test2内,我echo $PATH

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

我知道

/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

/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

@Uvar和@MSeifert指出我应该将路径变量指向正确的位置.我将尝试正确解决这个问题,但是我有两个问题:

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:

我注意到,如果我查看sys.paths,则test2中的python sys.path似乎在寻找numpy的正确位置.

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-包/setuptools-27.2.0-py2.7.egg']

['', '/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']

是否应该按照命令行,此sys.path变量或其他内容引用的方式更新$ PATH?

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

推荐答案

好.知道了!当我运行sys.path时,它会先出现在".local/lib/python2.7/site-packages"中,然后再出现在"anaconda3/envs/test2/lib/python2.7/site-packages"中

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"

我认为我从未在.local中使用python版本,因此我只是将python2.7目录移出了〜/.local/lib.这似乎可以解决该问题.现在,当我导入numpy时,版本是预期的.

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.

参考: 下面的讨论以及Uvar和MSeifert的评论,为我指明了解决此问题的方向.

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

这篇关于conda python没有使用numpy版本,如果我还指定它应该使用python 2,我会尝试安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆