用于Linux的Anaconda 3有没有ensurepip?

Men*_*ang 9 python python-venv anaconda

这是我的环境:

  • CentOS 64位7.2.1511

  • Anaconda 3 4.1.1 64位(Python 3.5.2)

我想通过创建venv虚拟环境pyvenv.不幸的是,我收到此错误消息:

$ 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.没有ensurepip文件夹.

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

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

Windows 10上的一个存档有一个ensurepip子文件夹.但是CentOS 7上没有!

有谁知道这个区别?这是Anaconda的错误吗?

YaO*_*OzI 16

是的,用于Linux和Mac OS的Anaconda3/2尚未ensurepip安装.

根据这个问题记录,它不是一个bug,这是在Anaconda中的Python没有标志的情况下有意识地完成的--with-ensurepip=install.

我认为(Continuum Analytics)的基本原理是,在Anaconda Distribution中,conda是管理软件包和虚拟环境的老大,

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

因此pyvenv test,您可以先运行pyvenv test --without-pip,然后get-pip.pypip的主页下载,然后在激活的 test venv中安装pip,而不是运行.

如下所示:

$ #===== First create the venv without pip, and **activate** it.
$ pyvenv test --without-pip
$ cd test/
$ ls bin/
activate       activate.csh   activate.fish  python@        python3@
$ 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*  python@   wheel*
activate.csh  easy_install*  pip*     pip3.5*   python3@
(test) $
(test) $ #===== Now you can play around with pip
(test) $ pip list
(test) $ 
Run Code Online (Sandbox Code Playgroud)