gpt4 book ai didi

Python 虚拟环境 (venv) 用户包

转载 作者:行者123 更新时间:2023-12-01 07:25:58 24 4
gpt4 key购买 nike

venv 是否存在用户包的概念?我激活了 venv,并尝试了:

$ pip3 install --user times2

但是,pip3 list 不显示软件包,而 pip3 uninstall times2 显示:

$ pip3 uninstall times2
Skipping times2 as it is not installed.

编辑:添加完整的打印输出:

rishai@mbp157:~$ python3 -m venv sw/venvsandbox2
rishai@mbp157:~$
rishai@mbp157:~$
rishai@mbp157:~$ source sw/venvsandbox2/bin/activate
(venvsandbox2) rishai@mbp157:~$
(venvsandbox2) rishai@mbp157:~$
(venvsandbox2) rishai@mbp157:~$ pip3 list
Package Version
---------- -------
pip 19.0.3
setuptools 40.8.0
You are using pip version 19.0.3, however version 19.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venvsandbox2) rishai@mbp157:~$ pip3 install --user times2
Collecting times2
Using cached https://files.pythonhosted.org/packages/e0/bc/22dbef03a9194dd4a7465a5a0be4b05f372fbdea7e9c59f0fd0caff8ca6f/times2-0.8-py2.py3-none-any.whl
Collecting python-dateutil (from times2)
Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl
Collecting pytz (from times2)
Using cached https://files.pythonhosted.org/packages/87/76/46d697698a143e05f77bec5a526bf4e56a0be61d63425b68f4ba553b51f2/pytz-2019.2-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil->times2)
Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, pytz, times2
Successfully installed python-dateutil-2.8.0 pytz-2019.2 six-1.12.0 times2-0.8
You are using pip version 19.0.3, however version 19.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venvsandbox2) rishai@mbp157:~$ pip3 list
Package Version
---------- -------
pip 19.0.3
setuptools 40.8.0
You are using pip version 19.0.3, however version 19.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venvsandbox2) rishai@mbp157:~$ python3
Python 3.7.4 (default, Jul 9 2019, 18:13:23)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import times2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'times2'
>>>

最佳答案

它确实存在,并且是你让它发生的。

您将 --user 参数传递给 pip,并指示它“将提供的包放在用户目录中,而不是默认目录中”。

您的情况的默认设置位于激活的虚拟环境内,如果您在调用之前没有激活它,那么它会安装在系统目录中。

停用您的环境,pip3 freeze 将显示该软件包,sudo pip3 freeze 不会显示它,在 GNU/Linux 中locate times2会在~/local/下面的某个地方找到它。

关于Python 虚拟环境 (venv) 用户包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57454339/

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