简体   繁体   English

为什么pip安装包不会出现在pip冻结中?

[英]Why doesn't pip installed package show up in pip freeze?

I am trying to install this package via pip. 我正在尝试通过pip安装此软件包 When I run pip install flask-googlemaps , I see the usual output, and the package is installed successfully, along with a handful of dependencies. 当我运行pip install flask-googlemaps ,我看到通常的输出,并且包已成功安装,还有一些依赖项。 If I then run pip freeze , I see all dependencies listed, but not the package itself. 如果我然后运行pip freeze ,我会看到列出的所有依赖项,但不是包本身。 Why? 为什么?

Here's a comprehensive breakdown of my process. 这是我的流程的全面细分。 I tested on a fresh virtualenv to make sure I wasn't just missing it. 我测试了一个新鲜的virtualenv,以确保我不只是错过它。

  1. $ mkvirtualenv test1

     New python executable in /Users/me/.virtualenvs/test1/bin/python2.7 Also creating executable in /Users/me/.virtualenvs/test1/bin/python Installing setuptools, pip, wheel...done. virtualenvwrapper.user_scripts creating /Users/me/.virtualenvs/test1/bin/predeactivate virtualenvwrapper.user_scripts creating /Users/me/.virtualenvs/test1/bin/postdeactivate virtualenvwrapper.user_scripts creating /Users/me/.virtualenvs/test1/bin/preactivate virtualenvwrapper.user_scripts creating /Users/me/.virtualenvs/test1/bin/postactivate virtualenvwrapper.user_scripts creating /Users/me/.virtualenvs/test1/bin/get_env_details 
  2. $ pip freeze

     (no results, because nothing has been installed yet) 
  3. $ pip install flask-googlemaps

     Collecting flask-googlemaps Using cached Flask_GoogleMaps-0.2.5-py2.py3-none-any.whl Collecting flask (from flask-googlemaps) Using cached Flask-0.12.2-py2.py3-none-any.whl Collecting Werkzeug>=0.7 (from flask->flask-googlemaps) Using cached Werkzeug-0.12.2-py2.py3-none-any.whl Collecting Jinja2>=2.4 (from flask->flask-googlemaps) Using cached Jinja2-2.9.6-py2.py3-none-any.whl Collecting click>=2.0 (from flask->flask-googlemaps) Using cached click-6.7-py2.py3-none-any.whl Collecting itsdangerous>=0.21 (from flask->flask-googlemaps) Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->flask->flask-googlemaps) Installing collected packages: Werkzeug, MarkupSafe, Jinja2, click, itsdangerous, flask, flask-googlemaps Successfully installed Jinja2-2.9.6 MarkupSafe-1.0 Werkzeug-0.12.2 click-6.7 flask-0.12.2 flask-googlemaps itsdangerous-0.24 
  4. $ pip freeze

     click==6.7 Flask==0.12.2 itsdangerous==0.24 Jinja2==2.9.6 MarkupSafe==1.0 Werkzeug==0.12.2 

Note that flask-googlemaps is not included in the second pip freeze output, but all of its dependencies are. 请注意,flask-googlemaps不包含在第二个pip冻结输出中,但它的所有依赖项都是。

What's even stranger is that I have full access to use the package now. 更奇怪的是,我现在可以完全使用该软件包。 It's installed, it just doesn't show up in pip freeze output. 它已安装,它只是没有显示在pip冻结输出中。

Took some time but I tracked it down. 花了一些时间,但我追查了它。

if you run 如果你跑

pip install -v flask-googlemaps

You will see at the end 你会在最后看到

Installing collected packages: Werkzeug, MarkupSafe, Jinja2, click, itsdangerous, flask, flask-googlemaps

  Compiling /private/var/folders/2h/0dr8jftd1916yq_lp40__wzh0000gn/T/pip-build-avapA_/Jinja2/jinja2/asyncfilters.py ...
    File "/private/var/folders/2h/0dr8jftd1916yq_lp40__wzh0000gn/T/pip-build-avapA_/Jinja2/jinja2/asyncfilters.py", line 7
      async def auto_to_seq(value):
              ^
  SyntaxError: invalid syntax

  Compiling /private/var/folders/2h/0dr8jftd1916yq_lp40__wzh0000gn/T/pip-build-avapA_/Jinja2/jinja2/asyncsupport.py ...
    File "/private/var/folders/2h/0dr8jftd1916yq_lp40__wzh0000gn/T/pip-build-avapA_/Jinja2/jinja2/asyncsupport.py", line 22
      async def concat_async(async_gen):
              ^
  SyntaxError: invalid syntax

To prove that this error is the cause of flask-googlemaps not showing up on pip freeze, I installed a previous version. 为了证明这个错误是烧瓶谷歌地图没有出现在pip冻结的原因,我安装了以前的版本。

pip install flask-googlemaps==0.2.4
Collecting flask-googlemaps==0.2.4
Collecting Flask (from flask-googlemaps==0.2.4)
  Using cached Flask-0.12.2-py2.py3-none-any.whl
Collecting Werkzeug>=0.7 (from Flask->flask-googlemaps==0.2.4)
  Using cached Werkzeug-0.12.2-py2.py3-none-any.whl
Collecting Jinja2>=2.4 (from Flask->flask-googlemaps==0.2.4)
  Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting click>=2.0 (from Flask->flask-googlemaps==0.2.4)
  Using cached click-6.7-py2.py3-none-any.whl
Collecting itsdangerous>=0.21 (from Flask->flask-googlemaps==0.2.4)
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask->flask-googlemaps==0.2.4)
Installing collected packages: Werkzeug, MarkupSafe, Jinja2, click, itsdangerous, Flask, flask-googlemaps
Successfully installed Flask-0.12.2 Jinja2-2.9.6 MarkupSafe-1.0 Werkzeug-0.12.2 click-6.7 flask-googlemaps-0.2.4 itsdangerous-0.24

Pip freeze now works Pip冻结现在有效

pip freeze
click==6.7
Flask==0.12.2
Flask-GoogleMaps==0.2.4
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
Werkzeug==0.12.2

I have just filed a GitHub issue on your behalf. 我刚刚代表您提交了GitHub问题

Wonton, 馄饨,

It is interesting that you ran into that issue. 有趣的是你遇到了这个问题。 I'm using python 3.6 and got no errors running 我正在使用python 3.6并且没有运行错误

pip install -v flask-googlemaps

It installed completely and I am able to use the package. 它完全安装,我可以使用该包。

I did a little poking around and this is what I discovered: 我做了一点点戳,这是我发现的:

site-packages has the following entries for flask-googlemaps site-packages为flask-googlemaps提供以下条目

flask_googlemaps
Flask-GoogleMaps-0.2.5-dist-info

I was able to get pip freeze to display flask-googlemaps by simply renaming the Flask-GoogleMaps-0.2.5-dist-info to match the formatting of flask_googlemap: 通过简单地重命名Flask-GoogleMaps-0.2.5-dist-info以匹配flask_googlemap的格式,我能够获得pip冻结以显示flask-googlemaps:

davidj> mv Flask-GoogleMaps-0.2.5.dist-info Flask_GoogleMaps-0.2.5.dist-info
davidj> pip freeze
clickk==6.7
Flask==0.12.2
Flask-GoogleMaps==0.2.5
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
pkg-resources==0.0.0
Werkzeug==0.12.2

after doing that, all of the pip functions work for the package. 在这之后,所有的pip函数都适用于包。

Perhaps pip has some required naming conventions to map the info directory to the package directory.... 也许pip有一些必要的命名约定来将info目录映射到包目录....

If you have multiple versions of python installed, pip can have unexpected behavior with respect to versions. 如果您安装了多个版本的python,则pip可能会有与版本相关的意外行为。 Make sure to explicitly use pip2 install or pip3 install , and pip2 freeze or pip3 freeze to match with the version of python that you intend to use. 确保明确使用pip2 installpip3 install ,并使用pip2 freezepip3 freeze来匹配你打算使用的python版本。

(Note: this answer may not be relevant to the OP's case, but answers the question "Why doesn't pip installed package show up in pip freeze?" for some other cases.) (注意:这个答案可能与OP的情况无关,但对于其他一些案例,回答了“为什么pip安装包不会出现在pip冻结?”的问题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM