简体   繁体   English

可以一一安装包但是不能使用pip install -r requirements.txt

[英]Can install packages one by one but cannot use pip install -r requirements.txt

I have establised a virtual enviroment by using python 3.6;我已经使用 python 3.6 建立了一个虚拟环境; the requirements.txt:要求.txt:

alembic==0.9.9
blinker==1.4
chardet==3.0.4
click==6.7
Flask==1.0.2
Flask-Dance==0.14.0
Flask-DebugToolbar==0.10.1
Flask-Login==0.4.1
Flask-Migrate==2.1.1
Flask-OAuth==0.12
Flask-OAuthlib==0.9.4
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
httplib2==0.11.3
idna==2.6
itsdangerous==0.24
Jinja2==2.10
lazy==1.3
Mako==1.0.7
MarkupSafe==1.0
oauth2==1.9.0.post1
oauthlib==2.0.7
python-dateutil==2.7.2
python-editor==1.0.3
requests==2.18.4
requests-oauthlib==0.8.0
six==1.11.0
SQLAlchemy==1.2.6
SQLAlchemy-Utils==0.33.2
urllib3==1.22
URLObject==2.4.3
Werkzeug==0.14.1
wincertstore==0.2
WTForms==2.1

The interesting thing is I can install the package one by one, for example:有趣的是我可以一个一个安装包,例如:

(mynewflaskenv) D:\pythonProject10>pip install alembic==0.9.9
Collecting alembic==0.9.9
  Using cached alembic-0.9.9.tar.gz (1.0 MB)
Collecting SQLAlchemy>=0.7.6
  Downloading SQLAlchemy-1.3.20-cp36-cp36m-win_amd64.whl (1.2 MB)
     |████████████████████████████████| 1.2 MB 2.2 MB/s
Collecting Mako
  Downloading Mako-1.1.3-py2.py3-none-any.whl (75 kB)
     |████████████████████████████████| 75 kB 5.1 MB/s
Collecting python-editor>=0.3
  Downloading python_editor-1.0.4-py3-none-any.whl (4.9 kB)
Collecting python-dateutil
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting MarkupSafe>=0.9.2
  Downloading MarkupSafe-1.1.1-cp36-cp36m-win_amd64.whl (16 kB)
Collecting six>=1.5
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Using legacy 'setup.py install' for alembic, since package 'wheel' is not installed.
Installing collected packages: SQLAlchemy, MarkupSafe, Mako, python-editor, six, python-dateutil, alembic
    Running setup.py install for alembic ... done
Successfully installed Mako-1.1.3 MarkupSafe-1.1.1 SQLAlchemy-1.3.20 alembic-0.9.9 python-dateutil-2.8.1 python-editor-1.0.4 six-1.15.0

But if I use pip install -r requirements.txt:但是如果我使用 pip install -r requirements.txt:

(mynewflaskenv) D:\pythonProject10>pip install -r requirements.txt
Collecting alembic==0.9.9
  Using cached alembic-0.9.9.tar.gz (1.0 MB)
Collecting blinker==1.4
  Using cached blinker-1.4.tar.gz (111 kB)
Collecting chardet==3.0.4
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting click==6.7
  Using cached click-6.7-py2.py3-none-any.whl (71 kB)
Collecting Flask==1.0.2
  Using cached Flask-1.0.2-py2.py3-none-any.whl (91 kB)
Collecting Flask-Dance==0.14.0
  Using cached Flask_Dance-0.14.0-py2.py3-none-any.whl (39 kB)
Collecting Flask-DebugToolbar==0.10.1
  Using cached Flask_DebugToolbar-0.10.1-py2.py3-none-any.whl (326 kB)
Collecting Flask-Login==0.4.1
  Using cached Flask-Login-0.4.1.tar.gz (14 kB)
Collecting Flask-Migrate==2.1.1
  Using cached Flask_Migrate-2.1.1-py2.py3-none-any.whl (13 kB)
Collecting Flask-OAuth==0.12
  Using cached Flask-OAuth-0.12.tar.gz (6.2 kB)
Collecting Flask-OAuthlib==0.9.4
  Using cached Flask-OAuthlib-0.9.4.tar.gz (34 kB)
Collecting Flask-SQLAlchemy==2.3.2
  Using cached Flask_SQLAlchemy-2.3.2-py2.py3-none-any.whl (16 kB)
Collecting Flask-WTF==0.14.2
  Using cached Flask_WTF-0.14.2-py2.py3-none-any.whl (14 kB)
Collecting httplib2==0.11.3
  Using cached httplib2-0.11.3.tar.gz (215 kB)
Collecting idna==2.6
  Using cached idna-2.6-py2.py3-none-any.whl (56 kB)
Collecting itsdangerous==0.24
  Using cached itsdangerous-0.24.tar.gz (46 kB)
Collecting Jinja2==2.10
  Using cached Jinja2-2.10-py2.py3-none-any.whl (126 kB)
Collecting lazy==1.3
  Using cached lazy-1.3.zip (15 kB)
Collecting Mako==1.0.7
  Using cached Mako-1.0.7.tar.gz (564 kB)
Collecting MarkupSafe==1.0
  Using cached MarkupSafe-1.0.tar.gz (14 kB)
    ERROR: Command errored out with exit status 1:
     command: 'd:\pythonproject10\mynewflaskenv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\
dell\\AppData\\Local\\Temp\\pip-install-4wzmja7p\\markupsafe\\setup.py'"'"'; __file__='"'"'C:\\Users\\dell\\AppData\\Local\\Temp\\pip-in
stall-4wzmja7p\\markupsafe\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"
'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\dell\AppData\Local\Temp\pip-pip-egg-inf
o-vwktxwrl'
         cwd: C:\Users\dell\AppData\Local\Temp\pip-install-4wzmja7p\markupsafe\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\dell\AppData\Local\Temp\pip-install-4wzmja7p\markupsafe\setup.py", line 6, in <module>
        from setuptools import setup, Extension, Feature
    ImportError: cannot import name 'Feature'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

(mynewflaskenv) D:\pythonProject10>pip install alembic==0.9.9
Collecting alembic==0.9.9
  Using cached alembic-0.9.9.tar.gz (1.0 MB)
Collecting SQLAlchemy>=0.7.6
  Downloading SQLAlchemy-1.3.20-cp36-cp36m-win_amd64.whl (1.2 MB)
     |████████████████████████████████| 1.2 MB 2.2 MB/s
Collecting Mako
  Downloading Mako-1.1.3-py2.py3-none-any.whl (75 kB)
     |████████████████████████████████| 75 kB 5.1 MB/s
Collecting python-editor>=0.3
  Downloading python_editor-1.0.4-py3-none-any.whl (4.9 kB)
Collecting python-dateutil
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting MarkupSafe>=0.9.2
  Downloading MarkupSafe-1.1.1-cp36-cp36m-win_amd64.whl (16 kB)
Collecting six>=1.5
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Using legacy 'setup.py install' for alembic, since package 'wheel' is not installed.
Installing collected packages: SQLAlchemy, MarkupSafe, Mako, python-editor, six, python-dateutil, alembic
    Running setup.py install for alembic ... done
Successfully installed Mako-1.1.3 MarkupSafe-1.1.1 SQLAlchemy-1.3.20 alembic-0.9.9 python-dateutil-2.8.1 python-editor-1.0.4 six-1.15.0

(mynewflaskenv) D:\pythonProject10>pip install -r requirements.txt
Requirement already satisfied: alembic==0.9.9 in d:\pythonproject10\mynewflaskenv\lib\site-packages (from -r requirements.txt (line 1))
(0.9.9)
Collecting blinker==1.4
  Using cached blinker-1.4.tar.gz (111 kB)
Collecting chardet==3.0.4
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting click==6.7
  Using cached click-6.7-py2.py3-none-any.whl (71 kB)
Collecting Flask==1.0.2
  Using cached Flask-1.0.2-py2.py3-none-any.whl (91 kB)
Collecting Flask-Dance==0.14.0
  Using cached Flask_Dance-0.14.0-py2.py3-none-any.whl (39 kB)
Collecting Flask-DebugToolbar==0.10.1
  Using cached Flask_DebugToolbar-0.10.1-py2.py3-none-any.whl (326 kB)
Collecting Flask-Login==0.4.1
  Using cached Flask-Login-0.4.1.tar.gz (14 kB)
Collecting Flask-Migrate==2.1.1
  Using cached Flask_Migrate-2.1.1-py2.py3-none-any.whl (13 kB)
Collecting Flask-OAuth==0.12
  Using cached Flask-OAuth-0.12.tar.gz (6.2 kB)
Collecting Flask-OAuthlib==0.9.4
  Using cached Flask-OAuthlib-0.9.4.tar.gz (34 kB)
Collecting Flask-SQLAlchemy==2.3.2
  Using cached Flask_SQLAlchemy-2.3.2-py2.py3-none-any.whl (16 kB)
Collecting Flask-WTF==0.14.2
  Using cached Flask_WTF-0.14.2-py2.py3-none-any.whl (14 kB)
Collecting httplib2==0.11.3
  Using cached httplib2-0.11.3.tar.gz (215 kB)
Collecting idna==2.6
  Using cached idna-2.6-py2.py3-none-any.whl (56 kB)
Collecting itsdangerous==0.24
  Using cached itsdangerous-0.24.tar.gz (46 kB)
Collecting Jinja2==2.10
  Using cached Jinja2-2.10-py2.py3-none-any.whl (126 kB)
Collecting lazy==1.3
  Using cached lazy-1.3.zip (15 kB)
Collecting Mako==1.0.7
  Using cached Mako-1.0.7.tar.gz (564 kB)
Collecting MarkupSafe==1.0
  Using cached MarkupSafe-1.0.tar.gz (14 kB)
    ERROR: Command errored out with exit status 1:
     command: 'd:\pythonproject10\mynewflaskenv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\
dell\\AppData\\Local\\Temp\\pip-install-lkdxc8hu\\markupsafe\\setup.py'"'"'; __file__='"'"'C:\\Users\\dell\\AppData\\Local\\Temp\\pip-in
stall-lkdxc8hu\\markupsafe\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"
'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\dell\AppData\Local\Temp\pip-pip-egg-inf
o-fg4ekrqp'
         cwd: C:\Users\dell\AppData\Local\Temp\pip-install-lkdxc8hu\markupsafe\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\dell\AppData\Local\Temp\pip-install-lkdxc8hu\markupsafe\setup.py", line 6, in <module>
        from setuptools import setup, Extension, Feature
    ImportError: cannot import name 'Feature'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Have a google like Pip install from requirements file is failing, but installing one by one works similar question, but different error term, and not be solved. 从需求文件中安装Pip这样的 google 失败,但是安装一个一个会解决类似的问题,但是错误术语不同,并且无法解决。 I am wondering can anyone share some solutions, others may also have this problem我想知道任何人都可以分享一些解决方案,其他人可能也有这个问题

This is because the dependencies are conflicting.这是因为依赖项是冲突的。 Installing one by one, you actually end up installing different (conflicting) versions.一个一个地安装,你实际上最终安装了不同的(冲突的)版本。

Notice:注意:

  Downloading MarkupSafe-1.1.1-cp36-cp36m-win_amd64.whl (16 kB)

But your requirements have MarkupSafe==1.0但是你的要求有MarkupSafe==1.0

Your best bet would probably be to only pin versions in your requirements.txt you know you need specific versions of.你最好的选择可能是只在你的requirements.txt知道你需要特定版本的版本。 Try unpinning or using < <= > or >= instead of == where possible.在可能的情况下尝试取消固定或使用< <= >>=而不是==

It's also worth noting that pip 's behavior is changing in regards to conflicting dependencies.还值得注意的是, pip的行为在依赖冲突方面正在发生变化。 So the version of pip you're using can be important, too.因此,您使用的 pip 版本也很重要。 Be sure to upgrade pip.一定要升级pip。

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

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