2016-07-22 39 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) $