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

2023-11-18

永久性添加pip安装源

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

可得到如下结果:
在这里插入图片描述
可见,配置信息被写入pip.ini文件中,而此pip.ini被存放在python安装路径下。
打开该配置文件,可见:

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

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

查看pip文件的存储位置有

pip -v config list

可见:
在这里插入图片描述
即,除了“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

在这里插入图片描述
把别处添加的源删除

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

python -m site

得见:
在这里插入图片描述
其中USER_BASEUSER_SITE即为pip下载的安装包位置,此时目录还不存在。

查看如何修改安装位置

python -m site -help

得见:
在这里插入图片描述
所以,去 D:\Program Files\Python39\lib\site.py 修改配置信息,
将:
在这里插入图片描述
修改为自建目录:
在这里插入图片描述

其中
USER_SITE用于存放执行所下载的安装包所需要的脚本或程序
USER_BASE为安装包的下载位置

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

随机推荐

  • Java——string[] 和List的区别

    一直对string 和List
  • JavaWeb之综合小项目

    案例需求 使用Java程序操作数据库 并把结果显示在jsp页面上 这里只做查询操作 增删改操作类似如此 使用工具 maven idea tomcat MySQL数据库 使用技术 javabean servlet jsp 准备阶段 第一步 使
  • 求全排列的数学方法(洛谷1088 火星人noip2004普及组第4题)

    人类终于登上了火星的土地并且见到了神秘的火星人 人类和火星人都无法理解对方的语言 但是我们的科学家发明了一种用数字交流的方法 这种交流方法是这样的 首先 火星人把一个非常大的数字告诉人类科学家 科学家破解这个数字的含义后 再把一个很小的数字
  • 实战wxPython:056 - GDI基本元素之颜色Colour

    GDI系统中的设备上下文包含一些基本元素 例如颜色 画刷 画笔或字体等等 wx Colour定义设备上下文中对象显示的颜色 wx Brush是一个用于填充区域的绘图工具 它用于绘制形状的背景 它有颜色和风格 wx Pen用于绘制形状的轮廓
  • 查询sql数据库中表占用的空间大小

    1 SQL统计数据 大量事务操作后可能不准 exec sp spaceused 表名 2 准确的表空间大小 但可能会花些统计时间 exec sp spaceused 表名 true 3 数据库大小查询 exec sp spaceused 4
  • 关于shiro doGetAuthorizationInfo授权方法和doGetAuthenticationInfo登陆认证方法的执行时机

    1 默认情况下不关闭shiro session 登陆时生成JESSIONID 执行doGetAuthorizationInfo的时机 1 subject hasRole admin 或 subject isPermitted admin 自
  • error: ‘FixedArray’ {aka ‘class ceres::internal::FixedArray<double, 3>’} has no member named ‘data’

    在使用g2o或者Ceres遇到以下问题 error FixedArray aka class ceres internal FixedArray
  • private static final Long serialVersionUID= 1L详解

    我们知道在对数据进行传输时 需要将其进行序列化 在Java中实现序列化的方式也很简单 可以直接通过实现Serializable接口 但是我们经常也会看到下面接这一行代码 private static final Long serialVer
  • R语言基础图形元素——坐标轴和网格线

    R语言基础图形元素 坐标轴和网格线 简介 1 坐标轴 2 网格线 参考书籍 简介 坐标轴为图中元素数值大小提供了参照 绘图时 时常需要实现坐标轴的个性化绘制 可以通过axis 函数实现 网格线是图形的一种辅助线 可以实现图中元素更加精确把控
  • R语言作图:坐标轴设置

    R语言作图 坐标轴设置 偷闲阁 2018 02 04 20 51 24 209654 收藏 359 分类专栏 R语言 可视化 文章标签 R 坐标轴 刻度 可视化 版权声明 本文为博主原创文章 遵循 C
  • 小白用Python抓取豆瓣高评分喜剧电影

    目的 抓取豆瓣高评分喜剧电影 导入所需的库 import requests 进行模拟浏览器进行发送请求 import json 导入JSON类型的库 不会导入库的话 请参考我的上一篇文章 上面有提及 小白如何抓取网页 进行确定URL和浏览器
  • 开发gitlab-reporting周报项目的总结

    一 方案设计 二 数据库设计 三 代码设计 从gitlab项目中输出每个成员的周报 事件触发webhook 接收webhook的server server解析webhook事件 做一个周报生成器 用gitlab的issues生成周报 功能
  • WebGL 视图矩阵、模型视图矩阵

    目录 立方体由三角形构成 视点和视线 视点 观察目标点和上方向 视点 观察目标点 上方向 在WebGL中 观察者的默认状态应该是这样的 视图矩阵程序 LookAtTriangles js 实际上 根据自定义的观察者状态 绘制观察者看到的景象
  • 【插件】谷歌浏览器插件visio在线打开vsdx文件

    下载地址
  • 【牛客C++入门】CPP10 判断成绩等级

    描述 键盘录入一个成绩 整数 判断并输出成绩的等级 如果用户输入成绩不合法 小于0或者大于100 则输出成绩不合法 90 100 优秀 80 89 良 70 79 中 60 69 及格 0 59 差 输入描述 输入学生的成绩 整数 输出描述
  • 最美应用API接口分析

    最美应用API接口分析 最美应用API接口分析一 请求版本列表1 1 API二 请求应用配置2 1 API2 2参数列表2 3 返回三 友盟更新3 1 API3 2参数列表3 3 返回四 appleStore应用信息4 1API4 2 返回
  • 发布npm包-简要记录

    1注册账号 注册npm账号 需要邮箱 激活npm账号 npm账号注册成功以后会收到邮件 邮件中有个链接 点进去进行激活 2创建项目 npm init 创建项目 name 命名规则 不能包含大写字母 空格及下滑线 version 创建时候默认
  • Shiro源码分析-初始化-SecurityManager

    源码分析的第一篇以SecurityManager的初始化为题 根据ini配置文件初始化shiro的代码主要为两段 解析ini文件为Ini对象 Factory
  • 电商行业常用指标

    首先要构建电商数据分析的基本指标体系 主要分为8个类指标 即 1 总体运营指标 从流量 订单 总体销售业绩 整体指标进行把控 起码对运营的电商平台有个大致了解 到底运营的怎么样 是亏是赚 2 网站流量指标 即对访问你网站的访客进行分析 基于
  • 【Python】pip安装源、pip config命令 及 pip安装包位置 等相关问题

    永久性添加pip安装源 查看pip文件的存储位置有 查看pip config 的配置方法 删除配置信息 查看pip下载的安装包的默认路径 查看如何修改安装位置 永久性添加pip安装源 pip config set global index