gpt4 book ai didi

python - 使用 --user 安装时 pip 位于何处?

转载 作者:行者123 更新时间:2023-11-28 18:40:51 25 4
gpt4 key购买 nike

我在没有 root 访问权限的 linux 机器上有一个帐户。 Python 和 pip 都安装了,但我不想安装他们的版本,我想安装我自己的 python。

所以我去了http://pip.readthedocs.org/en/latest/installing.html并下载了 get-pip.py。然后我像这样用现有的 python 运行它:

/usr/bin/python get-pip.py --user

然后输出是这样的:

/usr/lib/python2.6/site-packages/setuptools/command/install_scripts.py:3: UserWarning: Module pip was already imported from /tmp/tmpuuEbJv/pip.zip/pip/__init__.py, but /usr/lib/python2.6/site-packages is being added to sys.path
from pkg_resources import Distribution, PathMetadata, ensure_directory
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-1.5.6-py2.py3-none-any.whl#md5=4d4fb4b69df6731c7aea6300bc1f2
Downloading pip-1.5.6-py2.py3-none-any.whl (1.0MB): 1.0MB downloaded
Installing collected packages: pip
Successfully installed pip
Cleaning up...

但是现在新的 pip 安装在哪里?哪个目录?

最佳答案

根据 Alternate installation: the user scheme :

Files will be installed into subdirectories of site.USER_BASE (written as userbase hereafter). This scheme installs pure Python modules and extension modules in the same location (also known as site.USER_SITE). Here are the values for UNIX, including Mac OS X:

Type of file | Installation directory
-------------+---------------------------------------
modules | userbase/lib/pythonX.Y/site-packages
scripts | userbase/bin
data | userbase
C headers | userbase/include/pythonX.Y/distname

And here are the values used on Windows:

Type of file | Installation directory
-------------+---------------------------------------
modules | userbase\PythonXY\site-packages
scripts | userbase\Scripts
data | userbase
C headers | userbase\PythonXY\Include\distname

>>> import site
>>> site.USER_BASE # `falsetru` is my username.
'/home/falsetru/.local'
>>> os.path.join(site.USER_BASE, 'bin')
'/home/falsetru/.local/bin'

关于python - 使用 --user 安装时 pip 位于何处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26278704/

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