2016-07-22 40 views
7

这是我的环境:用于Linux的Anaconda 3没有surepip?

  • CentOS的64位1511年7月2日

  • 蟒蛇3 4.1.1 64位(Python的3.5.2)

我想通过pyvenv创建venv虚拟环境。不幸的是,我得到这个错误信息:

$ pyvenv test Error: Command '['/root/test/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

在网上搜索后,人们说,模块ensurepip丢失。我检查了我的Anaconda安装路径/opt/anaconda3/lib/python3.5。没有surepip文件夹。

然后,在我的Windows 10 64位上,我检查了我的Anaconda安装路径D:\win10\Anaconda3\Lib\。有一个surepip文件夹!我可以成功运行python -m venv test创建一个venv。

然后,我查了下载蟒蛇蟒蛇档案: D:\win10\Anaconda3\pkgs\python-3.5.2-0.tar.bz2在Windows 10 和 /opt/anaconda3/pkgs/python-3.5.2-0.tar.bz2在CentOS 7

的一个档案在Windows 10不具有ensurepip子文件夹。但是CentOS 7上的那个不是!

有没有人知道这个区别?它是Anaconda的缺陷吗?

回答

13

是的,用于Linux和Mac OS的Anaconda3/2没有安装ensurepip

this issue record,它是不是一个错误,这样做是故意 Anaconda的Python的无--with-ensurepip=install标志被编译。

我觉得理(连续分析的)是,在蟒蛇分布conda是管理包和虚拟环境中的老大,和

PIP(和它的setuptools的依赖)安装独立于Python 作为conda包

所以不是运行pyvenv test的,您可以先运行pyvenv test --without-pip,那么get-pip.pypip's homepage下载,并安装在点子激活test VENV。

就像如下:

$ #===== First create the venv without pip, and **activate** it. 
$ pyvenv test --without-pip 
$ cd test/ 
$ ls bin/ 
activate  activate.csh activate.fish [email protected]  [email protected] 
$ echo $PATH 
Whatever/Else:In/Your/System 
$ source bin/activate 
(test) $ echo $PATH 
/Users/YaOzI/test/bin:Whatever/Else:In/Your/System 
(test) $ 
(test) $ #===== Then install the pip independently. 
(test) $ python ~/Downloads/get-pip.py 
Collecting pip 
    Using cached pip-8.1.2-py2.py3-none-any.whl 
Collecting setuptools 
    Downloading setuptools-26.0.0-py2.py3-none-any.whl (459kB) 
    100% |████████████████████████████████| 460kB 1.3MB/s 
Collecting wheel 
    Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB) 
    100% |████████████████████████████████| 71kB 5.7MB/s 
Installing collected packages: pip, setuptools, wheel 
Successfully installed pip-8.1.2 setuptools-26.0.0 wheel-0.29.0 
(test) $ ls bin/ 
activate activate.fish  easy_install-3.5* pip3* [email protected] wheel* 
activate.csh easy_install* pip*  pip3.5* [email protected] 
(test) $ 
(test) $ #===== Now you can play around with pip 
(test) $ pip list 
(test) $