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為庫的名字,可以根據你想安裝的庫進行修改

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM