pip源的配置和方法

根据pip的官方文档:

pip配置源是可以用命令直接添加的:

第一个在全局添加的是清华大学的源。

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

第二个是备用的源也是清华大学的源:

sudo pip config set install.index-url https://pypi.tuna.tsinghua.edu.cn

写这些命令行是有实例的:

pip config set global.index-url https://example.org

pip config 

set 

global.index-url 

https://example.org 

仿着写就行。

我们再看看有关这个文件的位置:

 

 我用的sudo位置是/root/.config/pip/pip.conf

pip源的配置和方法_第1张图片

 

Configuration keys should be dot separated command and option name, with the special prefix “global” affecting any command. 
For example, 
“pip config set global.index-url https://example.org/” would configure the index url for all commands, 
but “pip config set download.timeout 10” would configure a 10 second timeout only for “pip download” commands.

 

 pip源的配置和方法_第2张图片

 sudo 的用处也知道了。

还有其他用法,在下面的官方说明书里很详细。

可以自建文件。pip.conf

位置好像不需要注意。直接建就行

这是建文件的文件内容:

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

 

pip config
Usage

Unix/macOS
python -m pip config [] list
python -m pip config [] [--editor ] edit

python -m pip config [] get command.option
python -m pip config [] set command.option value
python -m pip config [] unset command.option
python -m pip config [] debug

Windows
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 command.option

set: Set the command.option=value

unset: Unset the value associated with command.option

debug: List the configuration files and values defined under them

Configuration keys should be dot separated command and option name, with the special prefix “global” affecting any command. For example, “pip config set global.index-url https://example.org/” would configure the index url for all commands, but “pip config set download.timeout 10” would configure a 10 second timeout only for “pip download” commands.

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 to the user file by default.

Options

--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

 

你可能感兴趣的:(Linux基础部分,pip,python)