用pip安装软件包不会出现在pip列表中

时间:2019-03-31 09:28:53

标签: python pip virtualenv pipenv

我在macOS 10.14.4上的我的pipenv中安装任何python软件包时遇到问题。我已经在openCV中使用pipenv已有一段时间了,但是我需要sklearn和pandas。我可以用pip安装它们,成功了。但是,当我尝试pip list时,这些软件包没有出现。

我尝试过两种安装方式,第一种是我一直使用的方式:

(assignments-0VzU3jlg) ~/Doc/2018/A/com/a $ pip install pandas
Collecting pandas
  Using cached https://files.pythonhosted.org/packages/fc/43/fd867e3347559845c8f993059d410c50a1e18709f1c4d4b3b47323a06a37/pandas-0.24.2-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Requirement already satisfied: numpy>=1.12.0 in /Users/pieterdelobelle/.local/share/virtualenvs/assignments-0VzU3jlg/lib/python3.7/site-packages (from pandas) (1.16.2)
Collecting python-dateutil>=2.5.0 (from pandas)
  Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl
Collecting pytz>=2011k (from pandas)
  Using cached https://files.pythonhosted.org/packages/61/28/1d3920e4d1d50b19bc5d24398a7cd85cc7b9a75a490570d5a30c57622d34/pytz-2018.9-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil>=2.5.0->pandas)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, pytz, pandas
Successfully installed pandas-0.24.2 python-dateutil-2.8.0 pytz-2018.9 six-1.12.0

但是它不在pip list中,并且在python中的导入也失败了。

(assignments-0VzU3jlg) ~/Doc/2018/A/com/a $ pip list
Package       Version 
------------- --------
numpy         1.16.2  
opencv-python 4.0.0.21
pip           19.0.3  
setuptools    40.8.0  
wheel         0.33.1  

现在,由于该$ PATH可能被弄乱了,因此我尝试直接调用该pip,如下所示。但是问题仍然完全一样。

 ~/Doc/2018/A/com/a $ /Users/pieter/.local/share/virtualenvs/assignments-0VzU3jlg/bin/pip install pandas
Collecting pandas
  Using cached https://files.pythonhosted.org/packages/fc/43/fd867e3347559845c8f993059d410c50a1e18709f1c4d4b3b47323a06a37/pandas-0.24.2-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting pytz>=2011k (from pandas)
  Using cached https://files.pythonhosted.org/packages/61/28/1d3920e4d1d50b19bc5d24398a7cd85cc7b9a75a490570d5a30c57622d34/pytz-2018.9-py2.py3-none-any.whl
Collecting python-dateutil>=2.5.0 (from pandas)
  Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl
Requirement already satisfied: numpy>=1.12.0 in /Users/pieterdelobelle/.local/share/virtualenvs/assignments-0VzU3jlg/lib/python3.7/site-packages (from pandas) (1.16.2)
Collecting six>=1.5 (from python-dateutil>=2.5.0->pandas)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: pytz, six, python-dateutil, pandas
Successfully installed pandas-0.24.2 python-dateutil-2.8.0 pytz-2018.9 six-1.12.0
~/Doc/2018/A/com/a $ /Users/pieter/.local/share/virtualenvs/assignments-0VzU3jlg/bin/pip list
Package       Version 
------------- --------
numpy         1.16.2  
opencv-python 4.0.0.21
pip           19.0.3  
setuptools    40.8.0  
wheel         0.33.1  

现在,在virtualenv中正确安装openCV时遇到了一些问题,因此我可能已经做了一些事情来弄乱它。但是我不知道如何(尤其是第二次尝试)无法正确安装软件包...

作为参考,我正在使用pip 19.0.3

~/Doc/2018/A/com/a $ /Users/pieter/.local/share/virtualenvs/assignments-0VzU3jlg/bin/pip --version 
pip 19.0.3 from /Users/pieter/.local/share/virtualenvs/assignments-0VzU3jlg/lib/python3.7/site-packages/pip (python 3.7)

修改 我正在使用pipenv。 pipenv install pandas命令将pandas添加到pipfile,但不允许我使用它,甚至以后也不能在shell(pipenv shell)中使用。

 ~/Doc/2018/A/com/a $ pipenv install pandas
Installing pandas…
✔ Installation Succeeded 
Installing dependencies from Pipfile.lock (caa119)…
     ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 12/12 — 00:00:08
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
 ~/Doc/2018/A/com/a $ pipenv run python -c "import pandas as pd"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'

0 个答案:

没有答案