使用Anaconda的Python版本创建virtualenv

时间:2014-12-24 06:49:43

标签: python linux virtualenv anaconda graphlab

创建使用与机器的默认Python不同的Python版本的virtualenv时出错,而在机器上安装了Anaconda。 我创建了一个新的虚拟环境:

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

我创建了一个目录,机器默认为python2.6,而我需要python2.7。然后,我读了here并尝试了:

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 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:-1)

你能否简要介绍一下你如何安装这个版本的python。以及您尝试安装的操作系统。

如果你的Os默认是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&&制作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

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

希望你有一些想法。 :)