python - 使用 pip 安装软件包不会出现在 pip 列表中
问题描述
我在 macOS 10.14.4 上将任何 python 包安装到我的 pipenv 时遇到问题。一段时间以来,我一直在使用带有 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 中,但不允许我使用它,甚至在pipenv shell
之后的 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'
解决方案
推荐阅读
- r - 在不考虑子字符串的一部分的情况下检测字符串中的子字符串
- reactjs - 在 react js 中重新加载页面
- c# - 无法在 Visual Studio 中添加 SecuBSMPx.dll 库?
- kubernetes - 跟踪失败的 Kubernetes 作业日志
- java - 通过spring xml beans在父类中设置子类中不可用的属性
- python - 如何单击元素并从链接的 xml 文件(python)中解析文本?
- ios - 支持在 IOS 应用中将 SAML 登录会话共享给不同的供应商
- permissions - 如何将斜杠命令隐藏到特定用户或频道 Discord.js v13
- django - 如何使用 xhtml2pdf Django 将 html 内容拆分为 2 页
- android - Android 开发者指南的问题开始另一个活动?