【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题

这篇具有很好参考价值的文章主要介绍了【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

永久性添加pip安装源

pip config set global.index-url --site https://pypi.tuna.tsinghua.edu.cn/simple

可得到如下结果:
【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题
可见,配置信息被写入pip.ini文件中,而此pip.ini被存放在python安装路径下。
打开该配置文件,可见:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

显然,与配置参数中的 golbal.index-url 对应。(此处已经有一个之前设置的global)

查看pip文件的存储位置有

pip -v config list

可见:
【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题
即,除了“site”对应的目录,还有其他目录可能存放pip配置文件。

查看pip config 的配置方法

pip config -help

可见,下面的 [< file-option >] 参数,即为 --global 、–user 、–site,对应上面不同的目录。而–user是默认位置。

Usage:
  pip config [<file-option>] list
  pip config [<file-option>] [--editor <editor-path>] edit

  pip config [<file-option>] get name
  pip config [<file-option>] set name value
  pip config [<file-option>] unset name
  pip config [<file-option>] debug


Description:
  Manage local and global configuration.

  Subcommands:

  - list: List the active configuration (or from the file specified)
  - edit: Edit the configuration file in an editor
  - get: Get the value associated with name
  - set: Set the name=value
  - unset: Unset the value associated with name
  - debug: List the configuration files and values defined under them

  If none of --user, --global and --site are passed, a virtual
  environment configuration file is used if one is active and the file
  exists. Otherwise, all modifications happen on the to the user file by
  default.

Config Options:
  --editor <editor>           Editor to use to edit the file. Uses VISUAL or EDITOR environment variables if not provided.
  --global                    Use the system-wide configuration file only
  --user                      Use the user configuration file only
  --site                      Use the current environment configuration file only

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --no-input                  Disable prompting for input.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
  --no-color                  Suppress colored output
  --no-python-version-warning
                              Silence deprecation warnings for upcoming unsupported Pythons.
  --use-feature <feature>     Enable new functionality, that may be backward incompatible.
  --use-deprecated <feature>  Enable deprecated functionality, that will be removed in the future.

删除配置信息

pip config --user unset site.index-url
pip config --user globalsite.index-url

【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题
把别处添加的源删除

查看pip下载的安装包的默认路径

python -m site

得见:
【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题
其中USER_BASEUSER_SITE即为pip下载的安装包位置,此时目录还不存在。

查看如何修改安装位置

python -m site -help

得见:
【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题
所以,去 D:\Program Files\Python39\lib\site.py 修改配置信息,
将:
【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题
修改为自建目录:
【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题

其中
USER_SITE用于存放执行所下载的安装包所需要的脚本或程序
USER_BASE为安装包的下载位置文章来源地址https://www.toymoban.com/news/detail-484304.html

到了这里,关于【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Python的包安装工具——pip命令大全

    对于大多数使用Python的人来说,一定知道pip这个包安装工具,但是对pip可能还不是很了解,今天作者给大家介绍一下pip的命令,以方便灵活使用pip。 一、pip工具使用方法 pip的语法如下: pip command [options] 式中:command是pip的命令(见表1),也就是功能;[options]为选项,可省略。

    2024年02月06日
    浏览(31)
  • pip命令镜像源、镜像源、pip安装库、python、python镜像源、清华镜像源配置

    当你在使用Python的pip命令安装第三方库时,你可能会遇到一些无法连接到Python包索引源(PyPI)的问题。这些问题可能会影响到你的学习和开发进度,因为它们可能会导致你无法下载所需的软件包。在这种情况下,你可以使用Python的镜像源来解决这个问题。 镜像源是一个允许

    2024年02月15日
    浏览(34)
  • Python安装pip命令教程及更改镜像源

    1、官方地址:地址 2、解压完成后,我们进入pip-23.2.1文件目录,找到setup.py,打开cmd进入此目录,或者在文件地址中输入cmd打开,输入以下命令: 进l进行安装,安装完成之后出现finished说明安装成功 3、配置pip环境变量,因为我在上一篇安装python3.7.8教程(地址)中是在d盘下

    2024年02月15日
    浏览(33)
  • Python安装完成后执行pip命令报错:‘pip‘ 不是内部或外部命令,也不是可运行的程序

    解决办法: 已安装pip的情况下,把这个Scripts文件夹的目录添加到Path环境变量即可。   我的电脑 - 右键 属性 - 高级系统设置 - 环境变量 - path - 编辑:加入Scripts文件夹的目录    确定即可

    2024年02月12日
    浏览(47)
  • Python之pip命令指定安装源和版本

            用pip安装依赖包时默认访问 https://pypi.Python.org/simple/。该路径经常出现不稳定以及访问速度非常慢的情况,国内厂商提供的一些pipy镜像可以加快下载速度,目前可用的有:         清华:https://pypi.tuna.tsinghua.edu.cn/simple         阿里云:http://mirrors.aliyun.co

    2023年04月10日
    浏览(30)
  • Python第三方库(模块)下载和安装(使用pip命令)

    Python第三方库是由社区开发者编写的代码包,用于增强Python的功能和提供各种特定的功能。通常,这些库被打包为模块,可以通过使用Python包管理工具pip来下载和安装。 以下是使用pip下载和安装Python第三方库的详细步骤: 步骤1:检查Python环境和pip的安装情况 在安装Python第三

    2023年04月08日
    浏览(34)
  • python安装三方库教程:关于pip命令的一切,到底怎么用?

      看这篇文章的目录,大家会发现写的很详细,适合收藏哦。如果你是刚学python的小白也没关系!看完这篇文章,关于pip的一切你就懂了。   关于pip的命令需要使用命令行,那么打开命令行界面: win+s/win+r快捷键都行,然后输入cmd后回车就能调出命令行界面了   python以

    2023年04月27日
    浏览(27)
  • 修改pip默认安装位置

    默认安装位置是C:Users用户名AppDataRoamingPythonPython38Scripts。浅浅建议不把这些东西放到系统盘,而是放到 Python 自己的安装目录的对应的子目录中! 首先,使用如下命令 python -m site 查看 这里的 USER_BASE 和 USER_SITE 其实就是默认的通过 pip 自动下载的脚本和依赖安装包的基础

    2023年04月18日
    浏览(43)
  • pip安装opencv-python遇到的问题

    1.控制台出现这种情况就是版本过低,需要先升级版本,命令pip install -upgrade pip 2. 出现:Script file ‘D:PythonAnaconda3Scriptspip-script.py’ is not present 原因就是升级pip过程中删除了原对应的文件 缺少升级后的pip及对应目录下的pip-script的python文件,缺少什么我们就加什么文件就解

    2024年02月12日
    浏览(27)
  • 【Python】修改pip默认缓存位置

    pip默认缓存的位置是C:UsersusernameAppDataLocalpipcache,这占用了大量的C盘空间,我们可能想要改变此路径为D:Pythonpipcache。 做法是命令行中输入如下命令:pip config set global.cache-dir “D:Pythonpipcache” 得到反馈:Writing to C:UsersykAppDataRoamingpippip.ini 调整完毕 原文地址:https:

    2024年04月27日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包