【问题标题】:Anaconda 3 for Linux Has No ensurepip?Anaconda 3 for Linux 没有 ensurepip?
【发布时间】:2016-11-26 06:19:33
【问题描述】:

这是我的环境:

  • CentOS 64 位 7.2.1511

  • Anaconda 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。没有 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.bz2 在 CentOS 7 上。

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

有人知道这个区别吗?是Anaconda的bug吗?

【问题讨论】:

    标签: python anaconda python-venv


    【解决方案1】:

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

    根据this issue record,这不是一个错误,这是有意在Anaconda 中的Python 在没有--with-ensurepip=install 标志的情况下编译时完成的。

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

    pip(以及它的 setuptools 依赖项)独立于 Python 作为 conda 包安装。

    所以不用运行pyvenv test,你可以先运行pyvenv test --without-pip,然后从pip's homepage下载get-pip.py,然后在激活testvenv中安装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) $ 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-10
      • 2015-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多