配置(9) 解决"setuptools pip wheel failed with error code 1" 用anaconda的python创建virtual environments

对于系统自带的python,也就是所谓的vanilla python。我们往往选择virtualenv进行安装,但是如果系统默认的python环境是anaconda自带的,那么在执行命令的时候,会爆出如下错误

setuptools pip wheel failed with error code 1

对于Anaconda的python,我们如何设置一个虚拟环境呢?有两种办法。


一.使用conda安装virtualenv,执行如下命令

pip uninstall virtualenv
conda install virtualenv
virtualenv YourVirtualEnvName
这个方法亲测有效。

二.conda自带的创建虚拟环境的功能

  • 检查conda是否安装

    conda -V

  • 检查conda是否更新到最新版本

    conda update conda

  • 创建虚拟环境

    conda create -n YourVirtualEnvName python=x.x.x anaconda
    这个x.x.x是python的版本,可以通过命令conda search "^python$"找到可以使用的python版本号。

  • 激活虚拟环境

    source activate YourVirtualEnvName

  • 安装第三方包

    conda install -n YourVirtualEnvName [Package]
    如果没有加上-n YourVirtualEnvName,那么安装将会在系统python下执行

  • 失活虚拟环境

    source deactivate

  • 删除虚拟环境

    conda remove -n YourVirtualEnvName -all

猜你喜欢

转载自blog.csdn.net/gzhermit/article/details/78915999
今日推荐