gpt4 book ai didi

python - 使用 pip 或 pip3 在 Anaconda、Python、Jupyter 中安装包

转载 作者:行者123 更新时间:2023-12-01 08:31:28 25 4
gpt4 key购买 nike

我一直相信pip管理 python2 的包,并且 pip3对于一个人的Python 3。在我运行的JupyterHub服务器上,我习惯安装我们团队以root身份使用的包。做sudo -i然后pip3 install <package-name> 。有时,这使得 import <package-name>在 Jupyter 中使用 python3 笔记本工作。但往往不是。那么,如果我改为 pip install 后,可以从服务器上的笔记本(python3 的,所有笔记本)访问该包。这是为什么?

这就是我所拥有的:

~# which python 
/anaconda3/bin/python

~# which python3
/anaconda3/bin/python3

~# which pip
/anaconda3/bin/pip

~# which pip3
/anaconda3/bin/pip3

~# which jupyter
/anaconda3/bin/jupyter

最佳答案

我找到了问题的答案 here :

pip3 always operates on the Python3 environment only, as pip2 does with Python2. pip operates on whichever environment is appropriate to the context. For example if you are in a Python3 venv, pip will operate on the Python3 environment.

关于python - 使用 pip 或 pip3 在 Anaconda、Python、Jupyter 中安装包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53898905/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com