通过常规方式(即sudo -H pip3 install --user numpy==1.17
)安装numpy模块不允许使用该模块。
无法导入numpy,也不会在pip3冻结中列出
为解决这个问题,我使用了sudo -E pip3 install --upgrade numpy
,它允许我使用该模块,并且当我输入pip3冻结时,我也可以在列表中看到它。
尽管此问题已为numpy解决,但不适用于其他python模块,例如configparser 3.8.1
。
这是我到目前为止所做的
sudo -H pip3 install --user matplotlib
Collecting matplotlib
Downloading https://files.pythonhosted.org/packages/89/61/465fb3bfba684b0f53b5c4829c3c89e86e6fe9fdcdfda93e38f1788090f0/matplotlib-3.0.3-cp35-cp35m-manylinux1_x86_64.whl (13.0MB)
|████████████████████████████████| 13.0MB 20.1MB/s
Requirement already satisfied: numpy>=1.10.0 in /root/.local/lib/python3.5/site-packages (from matplotlib) (1.16.0)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
Downloading https://files.pythonhosted.org/packages/11/fa/0160cd525c62d7abd076a070ff02b2b94de589f1a9789774f17d7c54058e/pyparsing-2.4.2-py2.py3-none-any.whl (65kB)
|████████████████████████████████| 71kB 35.8MB/s
Collecting kiwisolver>=1.0.1 (from matplotlib)
Downloading https://files.pythonhosted.org/packages/ee/18/4cd2e84c6aff0c6a50479118083d20b9e676e5175a913c0ea76d700fc244/kiwisolver-1.1.0-cp35-cp35m-manylinux1_x86_64.whl (90kB)
|████████████████████████████████| 92kB 39.6MB/s
Collecting python-dateutil>=2.1 (from matplotlib)
Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
|████████████████████████████████| 235kB 56.2MB/s
Collecting cycler>=0.10 (from matplotlib)
Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from kiwisolver>=1.0.1->matplotlib) (20.7.0)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.1->matplotlib) (1.10.0)
Installing collected packages: pyparsing, kiwisolver, python-dateutil, cycler, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.0.3 pyparsing-2.4.2 python-dateutil-2.8.0
Then enter
pip3 freeze
blinker==1.3
chardet==2.3.0
cloud-init==19.1
command-not-found==0.3
configobj==5.0.6
cryptography==1.2.3
hibagent==1.0.1
idna==2.0
Jinja2==2.8
jsonpatch==1.10
jsonpointer==1.9
language-selector==0.1
MarkupSafe==0.23
numpy==1.17.1
oauthlib==1.0.3
prettytable==0.7.2
pyasn1==0.1.9
pycurl==7.43.0
pygobject==3.20.0
PyJWT==1.3.0
pyserial==3.0.1
python-apt==1.1.0b1+ubuntu0.16.4.5
python-debian==0.1.27
python-systemd==231
PyYAML==3.11
requests==2.9.1
six==1.10.0
ssh-import-id==5.5
ufw==0.35
unattended-upgrades==0.1
urllib3==1.13.1
Then enter
sudo -E pip3 install --upgrade matplotlib
Then enter
pip3 freeze
blinker==1.3
chardet==2.3.0
cloud-init==19.1
command-not-found==0.3
configobj==5.0.6
cryptography==1.2.3
cycler==0.10.0
hibagent==1.0.1
idna==2.0
Jinja2==2.8
jsonpatch==1.10
jsonpointer==1.9
kiwisolver==1.1.0
language-selector==0.1
MarkupSafe==0.23
matplotlib==3.0.3
numpy==1.17.1
oauthlib==1.0.3
prettytable==0.7.2
pyasn1==0.1.9
pycurl==7.43.0
pygobject==3.20.0
PyJWT==1.3.0
pyparsing==2.4.2
pyserial==3.0.1
python-apt==1.1.0b1+ubuntu0.16.4.5
python-dateutil==2.8.0
python-debian==0.1.27
python-systemd==231
PyYAML==3.11
requests==2.9.1
six==1.10.0
ssh-import-id==5.5
ufw==0.35
unattended-upgrades==0.1
urllib3==1.13.1
我希望能够在安装pip3之后直接使用这些模块,但是这些模块未在pip3冻结列表中列出
答案 0 :(得分:0)
我认为您已经安装了numpy的多个版本。首先尝试将其全部删除
sudo apt-get remove numpy
或
pip3 uninstall numpy
然后重新安装
答案 1 :(得分:0)
尝试使用Anaconda,它还包含很多对您的工作有用的软件包。