无法使用pip

时间:2019-09-05 17:18:10

标签: python django pip

更新/解决方案:

在此问题的答案中找到了解决方法/解决方法: Pip installing packages to global site-packages when inside virtual environment。 像该问题的OP一样,我也正在运行具有最新更新的Manjaro Linux。

当尝试将带有pip install django-import-export的django import_export模块安装到我的虚拟环境中时,表明已成功安装,但是,当我尝试在项目中使用import_export模块时,收到错误消息:{ {1}}。我也无法列出以前使用ModuleNotFoundError: No module named 'import_export'pip list安装的应用程序,并且尝试使用pip freeze升级pip版本还表示已成功安装新版本,但未成功安装安装在我的虚拟环境中。

我已确保使用pip install --upgrade pip激活我的虚拟环境。

source /home/travis/Documents/Python/Django/Projects/issuetracker/.env/bin/activate的输出:

pip install django-import-export

Python版本:

(.env) [travis@spooky issuetracker]$ pip install django-import-export
Collecting django-import-export
  Using cached https://files.pythonhosted.org/packages/62/7a/ddd9aef718243504e7715bda9bb5a100cfc353be37dc819d9914a7073cba/django_import_export-1.2.0-py2.py3-none-any.whl
Collecting tablib (from django-import-export)
  Using cached https://files.pythonhosted.org/packages/7b/c7/cb74031b330cd94f3580926dc707d148b4ba9138449fc9f433cb79e640d8/tablib-0.13.0-py3-none-any.whl
Collecting diff-match-patch (from django-import-export)
  Using cached https://files.pythonhosted.org/packages/f0/2a/5ba07def0e9107d935aba62cf632afbd0f7c723a98af47ccbcab753d2452/diff-match-patch-20181111.tar.gz
Requirement already satisfied: django>=1.8 in ./.env/lib/python3.7/site-packages (from django-import-export) (2.2.4)
Collecting openpyxl>=2.4.0 (from tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/f5/39/942a406621c1ff0de38d7e4782991b1bac046415bf54a66655c959ee66e8/openpyxl-2.6.3.tar.gz
Collecting xlwt (from tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/44/48/def306413b25c3d01753603b1a222a011b8621aed27cd7f89cbc27e6b0f4/xlwt-1.3.0-py2.py3-none-any.whl
Collecting xlrd (from tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/b0/16/63576a1a001752e34bf8ea62e367997530dc553b689356b9879339cf45a4/xlrd-1.2.0-py2.py3-none-any.whl
Collecting backports.csv (from tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/8e/26/a6bd68f13e0f38fbb643d6e497fc3462be83a0b6c4d43425c78bb51a7291/backports.csv-1.0.7-py2.py3-none-any.whl
Collecting odfpy (from tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/85/7d/8f6d1f2a4683be362b101c00232b4c3839e4e4a90e0945d8d43ec6aa671d/odfpy-1.4.0.tar.gz
Collecting pyyaml (from tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/e3/e8/b3212641ee2718d556df0f23f78de8303f068fe29cdaa7a91018849582fe/PyYAML-5.1.2.tar.gz
Requirement already satisfied: sqlparse in ./.env/lib/python3.7/site-packages (from django>=1.8->django-import-export) (0.3.0)
Requirement already satisfied: pytz in ./.env/lib/python3.7/site-packages (from django>=1.8->django-import-export) (2019.2)
Collecting jdcal (from openpyxl>=2.4.0->tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/f0/da/572cbc0bc582390480bbd7c4e93d14dc46079778ed915b505dc494b37c57/jdcal-1.4.1-py2.py3-none-any.whl
Collecting et_xmlfile (from openpyxl>=2.4.0->tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/22/28/a99c42aea746e18382ad9fb36f64c1c1f04216f41797f2f0fa567da11388/et_xmlfile-1.0.1.tar.gz
Collecting defusedxml (from odfpy->tablib->django-import-export)
  Using cached https://files.pythonhosted.org/packages/06/74/9b387472866358ebc08732de3da6dc48e44b0aacd2ddaa5cb85ab7e986a2/defusedxml-0.6.0-py2.py3-none-any.whl
Installing collected packages: jdcal, et-xmlfile, openpyxl, xlwt, xlrd, backports.csv, defusedxml, odfpy, pyyaml, tablib, diff-match-patch, django-import-export
  Running setup.py install for et-xmlfile ... done
  Running setup.py install for openpyxl ... done
  Running setup.py install for odfpy ... done
  Running setup.py install for pyyaml ... done
  Running setup.py install for diff-match-patch ... done
Successfully installed backports.csv-1.0.7 defusedxml-0.6.0 diff-match-patch-20181111 django-import-export-1.2.0 et-xmlfile-1.0.1 jdcal-1.4.1 odfpy-1.4.0 openpyxl-2.6.3 pyyaml-5.1.2 tablib-0.13.0 xlrd-1.2.0 xlwt-1.3.0
WARNING: You are using pip version 19.2.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Pip版本:

(.env) [travis@spooky issuetracker]$ python -V
Python 3.7.4

.env / bin / pip:

(.env) [travis@spooky issuetracker]$ pip -V
pip 19.2.2 from /home/travis/Documents/Python/Django/Projects/issuetracker/.env/lib/python3.7/site-packages/pip (python 3.7)

我不确定这何时停止工作,因为我以前能够将其他软件包成功安装到同一虚拟环境中。如何确保pip将软件包正确安装到我的虚拟环境中?

更新:

似乎pip安装在.local / lib / python3.7 / site-packages目录中,而不是.env / lib / python3.7 / site-packages。

1 个答案:

答案 0 :(得分:0)

在此问题的答案中找到了解决方法/解决方法:

Pip installing packages to global site-packages when inside virtual environment

就像该问题的OP一样,我也在运行Manjaro Linux,具有最新更新。