ubuntu系统下安装pip3及第三方库的安装

ubuntu系统下会自带python2.x和python3.x坏境,不需要我们去安装。并且ubuntu系统下还会自动帮助我们安装python2.x坏境下的pip安装工具,

但是没有python3.x坏境下的pip3安装工具需要我们手动安装。

(1)安装pip3

首先输入命令$:python3-v

查看python3的具体版本,我这里是python3.6.

然后开始安装pip3,输入命令$:sudo apt-get install python3-pip

自己下载并进行安装,完成后,输入命令$:pip3-v查看pip3的版本

*这里要注意 一定要更新pip3

输入命令$:pip install --upgrade pip

更新好pip3之后

(2)配置pip3

一定要以管理员的身份进行修改

首先要找到pip的配置文件,命令为

$:cd usr

$:cd bin

在以管理员的身份打开,否则没有权限修改

输入命令$:sudo vi /usr/bin/pip

将pip中的配置文件修改为以下

from pip import __main__

if __name__=='__main__':

sys.exit(__main__._main())

**如果上面的错了,就把文件先改回去,然后再按照这个方法修改,直至你输入pip会出现各种命令使用方法,说明就成功了。

若成功如下

zztsj@zztsj-Nitro-AN515-51:/usr/bin$ pip3

Usage:   
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

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

(3)安装第三方库

输入命令为$:pip3 install lxml

其中lxml为库的名字,可以根据你想安装的库进行修改

上一篇:ubuntu系统下创建软件桌面快捷方式


下一篇:制作Windows服务项目详细攻略