我最近升级到ubuntu 20.04 LTS
. 按照python3.8
预装的方式,我使用命令安装了 pip sudo apt install python3-pip
,然后开始安装 python3 库。我安装的所有库都被安装到~/.local/lib/Python3.8/site-packages
文件夹中。如果我没记错的话,这些包应该安装到/usr/local/lib/python3.8/dist-packages
.
madhan@madhan:~$ pip3 show tensorflow
Name: tensorflow
Version: 2.2.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/madhan/.local/lib/python3.8/site-packages
安装软件包后,我收到警告说 ~/.local/bin 未包含在 $PATH 变量中。
Installing collected packages: appdirs, cachelib, pygments, cssselect, lxml, pyquery, howdoi
WARNING: The script pygmentize is installed in '/home/madhan/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script howdoi is installed in '/home/madhan/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed appdirs-1.4.4 cachelib-0.1 cssselect-1.1.0 howdoi-1.2.1 lxml-4.5.1 pygments-2.6.1 pyquery-1.4.1
即使 ~/.local/bin 不包含在 $PATH 变量中,我仍然可以导入包。
madhan@madhan:~$ python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>
有谁知道为什么会这样?如何更改安装 pip3 包的默认文件夹。可以将包留在 ~/.local 文件夹中还是将来会成为问题?