在conda环境中引用的全局点

时间:2018-07-25 17:58:53

标签: pip conda

总而言之,我仅安装pip创建并激活一个conda环境。然后,我列出了环境中的pip软件包,并安装了所有全局软件包。我检查了pip指向的位置,并正确指向了新创建的环境。那么为什么要列出我的全局软件包?此外,我确认可以加载软件包。任何帮助深表感谢!您可以在zsh提示符下看到我在这里运行的所有代码:

res = q[0]; 
for(j=1; j*du < h; j++) { res += q[j]; }
res *= pow(du, K);

如您所见,➜ ~ git:(master) ✗ conda create -n pip_test_env pip Solving environment: done ## Package Plan ## environment location: /Users/ethankeller/miniconda3/envs/pip_test_env added / updated specs: - pip The following NEW packages will be INSTALLED: ca-certificates: 2018.4.16-0 conda-forge certifi: 2018.4.16-py36_0 conda-forge ncurses: 6.1-0 conda-forge openssl: 1.0.2o-0 conda-forge pip: 18.0-py36_0 conda-forge python: 3.6.5-1 conda-forge readline: 7.0-haf1bffa_1 conda-forge setuptools: 40.0.0-py36_0 conda-forge sqlite: 3.20.1-0 conda-forge tk: 8.6.8-0 conda-forge wheel: 0.31.1-py36_0 conda-forge xz: 5.2.3-0 conda-forge zlib: 1.2.11-h470a237_3 conda-forge Proceed ([y]/n)? y Preparing transaction: done Verifying transaction: done Executing transaction: done # # To activate this environment, use # # $ conda activate pip_test_env # # To deactivate an active environment, use # # $ conda deactivate ➜ ~ git:(master) ✗ conda activate pip_test_env (pip_test_env) ➜ ~ git:(master) ✗ which pip /Users/ethankeller/miniconda3/envs/pip_test_env/bin/pip (pip_test_env) ➜ ~ git:(master) ✗ pip list Package Version ------------------------ --------- aide-design 0.0.12 alabaster 0.7.11 atomicwrites 1.1.5 attrs 18.1.0 Babel 2.6.0 certifi 2018.4.16 chardet 3.0.4 codecov 2.0.15 coverage 4.5.1 cycler 0.10.0 docutils 0.14 idna 2.7 imagesize 1.0.0 Jinja2 2.10 kiwisolver 1.0.1 latexcodec 1.0.5 MarkupSafe 1.0 matplotlib 2.2.2 more-itertools 4.2.0 numpy 1.14.5 oset 0.1.3 packaging 17.1 pandas 0.23.3 Pint 0.8.1 pip 18.0 pipenv 2018.7.1 pluggy 0.6.0 py 1.5.4 pybtex 0.21 pybtex-docutils 0.2.1 Pygments 2.2.0 pyparsing 2.2.0 pytest 3.6.3 pytest-cov 2.5.1 python-dateutil 2.7.3 pytz 2018.5 PyYAML 3.13 requests 2.19.1 ruamel.yaml 0.15.44 scipy 1.1.0 setuptools 40.0.0 six 1.11.0 snowballstemmer 1.2.1 Sphinx 1.7.6 sphinx-rtd-theme 0.4.0 sphinxcontrib-bibtex 0.4.0 sphinxcontrib-disqus 1.1.0 sphinxcontrib-websupport 1.1.0 urllib3 1.23 virtualenv 16.0.0 virtualenv-clone 0.3.0 wheel 0.31.1 (pip_test_env) ➜ ~ git:(master) ✗ (pip_test_env) ➜ ~ git:(master) ✗ pip --version pip 18.0 from /Users/ethankeller/.local/lib/python3.6/site-packages/pip (python 3.6) which pip显示两个不同的位置。为什么?如何使用正确的(环境)pip包?

1 个答案:

答案 0 :(得分:1)

您已经回答了自己的问题。

仔细查看:

(pip_test_env) ➜  ~ git:(master) ✗ which pip
/Users/ethankeller/miniconda3/envs/pip_test_env/bin/pip

(pip_test_env) ➜  ~ git:(master) ✗ pip --version
pip 18.0 from /Users/ethankeller/.local/lib/python3.6/site-packages/pip (python 3.6)

它正在从conda环境中拾取pip可执行文件,但是pip本身是从~/.local/lib/python3.6/site-packages/pip拾取其内部信息

对此问题有很多引用:

直到有正式的解决方案,您可以执行以下任一操作:

echo "include-system-site-packages=false" >> $CONDA_PREFIX/pyvenv.cfg

OR:

export PYTHONNOUSERSITE=1

更多参考文献: