使用Anaconda的Python版本创建虚拟环境

3

在安装了Anaconda的计算机上,创建一个使用与机器默认Python版本不同的Python虚拟环境时出现了错误。

我创建了一个新的虚拟环境:

virtualenv --no-site-packages ~/graphlabcreate
source ~/graphlabcreate/bin/activate

我创建了一个目录,使用了默认的Python2.6版本,但我需要Python2.7版本。然后,我在这里阅读并尝试:

virtualenv -p /usr/local/anaconda/bin/python2.7 ~/graphlabcreate

但是,我收到了以下错误信息:

Running virtualenv with interpreter /usr/local/anaconda/bin/python2.7
New python executable in /home/nancy/graphlabcreate/bin/python2.7
Not overwriting existing python script /home/nancy/graphlabcreate/bin/python (you must use /home/nancy/graphlabcreate/bin/python2.7)
/home/nancy/graphlabcreate/bin/python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable /home/nancy/graphlabcreate/bin/python2.7 is not functioning
ERROR: It thinks sys.prefix is u'/' (should be u'/home/nancy/graphlabcreate')
ERROR: virtualenv is not compatible with this system or executable

当我运行以下命令时,同样的事情也会发生:

virtualenv -p  /usr/local/anaconda/bin/python2.7  --no-site-packages ~/graphlabcreate

编辑:

$ ls -ltr /usr/bin/pyth*
-rwxr-xr-x. 1 root root 1418 2013-11-21 17:51 /usr/bin/python2.6-config*
-rwxr-xr-x. 3 root root 9032 2013-11-21 17:53 /usr/bin/python2.6*
-rwxr-xr-x. 3 root root 9032 2013-11-21 17:53 /usr/bin/python*
lrwxrwxrwx. 1 root root    6 2014-07-15 12:51 /usr/bin/python2 -> python*
lrwxrwxrwx. 1 root root   16 2014-07-15 12:56 /usr/bin/python-config -> python2.6-config*

 $ ls -ltr /usr/local/anaconda/bin/pyth*
    -rwxr-xr-x. 3 root root  9032 2013-11-21 17:53 /usr/local/anaconda/bin/python*
    -rwxr-xr-x. 1 root root 10222 2014-06-02 20:35 /usr/local/anaconda/bin/python2.7*
    -rwxrwxr-x. 1 root root  1602 2014-07-16 17:21 /usr/local/anaconda/bin/python-argcomplete-check-easy-install-script*
    lrwxrwxrwx. 1 root root     9 2014-07-16 17:21 /usr/local/anaconda/bin/python2 -> python2.7*
    -rwxr-xr-x. 1 root root  1680 2014-07-16 17:21 /usr/local/anaconda/bin/python-config*
2个回答

1
如果您使用Anaconda,可以使用conda而不是virtualenv创建环境,使用conda create命令。

-1

你能简要说明一下,你是如何安装这个版本的Python的。并且你正在尝试在哪个操作系统上进行安装。

如果python2.6是你的操作系统默认版本。那么你需要为其他更新版本的python进行alt安装(这样它就不会与你的操作系统冲突),并创建到python的符号链接

类似下面这样

tar -zxvf Python-2.7.6.tgz

cd Python-2.7.6

./configure --prefix=/usr/local --with-threads --enable-shared

make && make altinstall

ln -s /usr/local/bin/python /usr/bin/python2.7

echo '/usr/local/lib' >> /etc/ld.so.conf.d/usr-python2.7.conf

ldconfig

之后,您可以尝试安装虚拟环境库,然后尝试您现在正在做的事情。

希望你有所了解。 :)


操作系统:CentOS 6。我不记得我是如何安装Python版本的,但Anaconda包含Python2.7。 - Serendipity
似乎我已经有一个链接: $ ~/graphlabcreate/bin$ ll 总共 12 lrwxrwxrwx. 1 nancy nancy 9 2014-12-24 08:43 python -> python2.7* lrwxrwxrwx. 1 nancy nancy 9 2014-12-24 08:43 python2 -> python2.7* -rwxr-xr-x. 1 nancy nancy 10222 2014-12-24 08:43 python2.7* - Serendipity
请验证以下链接:https://github.com/h2oai/h2o/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only。这可能会有用,与在CentOS机器上安装Python 2.7相关。 - vijay
谢谢,但这与我已经在机器上完美运行的Python 2.7无关。看起来我已经有一个链接 - 我编辑了我的问题,请参见上面。谢谢! - Serendipity

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接