简体   繁体   English

使用 pip 安装 requirements.txt

[英]Install requirements.txt with pip

I am trying to install remote environment like on remote server using requirements.txt.我正在尝试使用 requirements.txt 在远程服务器上安装远程环境。

So first I went to Server went to virtualenv by所以首先我去服务器去virtualenv by

source bin/activate and typed: source bin/activate并输入:

pip freeze > requirements.txt 

then on my Windows machine I run:然后在我的 Windows 机器上运行:

pip2 install -r requirements.txt

I have currently Python27 on Server and Windos machine.我目前在服务器和 Windows 机器上有 Python27。

This is output on my Windows 8:这是我的 Windows 8 上的输出:

Collecting Cap1xxx==0.1.3 (from -r requirements.txt (line 1))
  Using cached Cap1xxx-0.1.3.tar.gz
Collecting ExplorerHAT==0.4.2 (from -r requirements.txt (line 2))
  Using cached ExplorerHAT-0.4.2.tar.gz
Collecting Flask==0.10.1 (from -r requirements.txt (line 3))
  Using cached Flask-0.10.1.tar.gz
Collecting Jinja2==2.7.3 (from -r requirements.txt (line 4))
  Using cached Jinja2-2.7.3.tar.gz
Collecting MarkupSafe==0.23 (from -r requirements.txt (line 5))
  Using cached MarkupSafe-0.23.tar.gz
Collecting Pillow==2.6.1 (from -r requirements.txt (line 6))
  Using cached Pillow-2.6.1-cp27-none-win32.whl
Collecting ................. and so on


Collecting urllib3==1.9.1 (from -r requirements.txt (line 43))
  Using cached urllib3-1.9.1-py2-none-any.whl
Requirement already satisfied: virtualenv==15.1.0 in c:\python27\lib\site-packages (from -r requirements.txt (line 44))
Collecting wheel==0.24.0 (from -r requirements.txt (line 45))
  Using cached wheel-0.24.0-py2.py3-none-any.whl
Collecting wsgiref==0.1.2 (from -r requirements.txt (line 46))
  Using cached wsgiref-0.1.2.zip
Collecting RPi.GPIO (from Cap1xxx==0.1.3->-r requirements.txt (line 1))
  Using cached RPi.GPIO-0.6.3.tar.gz
Collecting PyOpenSSL (from ndg-httpsclient==0.3.2->-r requirements.txt (line 22))
Collecting and everything is fine
.............................

And then there is a traceback:然后有一个回溯:

Running setup.py install for RPi.GPIO ... error
        Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\3c8a~1\\appdata\\local\\temp\\pip-build-tvvec2\\RPi.GPIO\\setup.py';f=
    getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\3c8a~1\appdata\local\temp\pip
    -kql53i-record\install-record.txt --single-version-externally-managed --compile:
        running install
        running build
        running build_py
        creating build
        creating build\lib.win32-2.7
        creating build\lib.win32-2.7\RPi
        copying RPi\__init__.py -> build\lib.win32-2.7\RPi
        creating build\lib.win32-2.7\RPi\GPIO
        copying RPi\GPIO\__init__.py -> build\lib.win32-2.7\RPi\GPIO
        running build_ext
        building 'RPi._GPIO' extension
        creating build\temp.win32-2.7
        creating build\temp.win32-2.7\Release
        creating build\temp.win32-2.7\Release\source
        C:\Users\Иван\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\python27\include -Ic:\python27\PC /Tcsourc
    e/py_gpio.c /Fobuild\temp.win32-2.7\Release\source/py_gpio.obj
        py_gpio.c
        source/py_gpio.c(87) : error C2143: syntax error : missing ';' before '{'
        source/py_gpio.c(200) : error C2143: syntax error : missing ';' before '{'
        source/py_gpio.c(227) : warning C4047: 'return' : 'PyObject *' differs in levels of indirection from 'int'
        source/py_gpio.c(345) : error C2373: 'output' : redefinition; different type modifiers
                c:\users\Ёў -\appdata\local\temp\pip-build-tvvec2\rpi.gpio\source\constants.h(29) : see declaration of 'output'
        source/py_gpio.c(345) : error C2143: syntax error : missing ';' before '{'
        source/py_gpio.c(359) : warning C4047: 'return' : 'PyObject *' differs in levels of indirection from 'int'
        error: command 'C:\\Users\\\xc8\xe2\xe0\xed\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

This is my requirements.txt:这是我的 requirements.txt:

Cap1xxx==0.1.3
ExplorerHAT==0.4.2
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
Pillow==2.6.1
Werkzeug==0.9.6
argparse==1.2.1
automationhat==0.0.4
blinker==1.3
blinkt==0.1.0
chardet==2.3.0
colorama==0.3.2
drumhat==0.0.5
envirophat==0.0.6
fourletterphat==0.0.2
html5lib==0.999
itsdangerous==0.24
microdotphat==0.1.3
mote==0.0.3
motephat==0.0.2
ndg-httpsclient==0.3.2
numpy==1.8.2
phatbeat==0.0.2
pianohat==0.0.5
picamera==1.13
picraft==1.0
piglow==1.2.4
pyasn1==0.1.7
pyserial==2.6
rainbowhat==0.0.2
requests==2.4.3
scrollphat==0.0.7
scrollphathd==1.0.1
sense-emu==1.0
sense-hat==2.2.0
six==1.8.0
skywriter==0.0.7
sn3218==1.2.7
spidev==3.0
touchphat==0.0.1
twython==3.1.2
urllib3==1.9.1
virtualenv==15.1.0
wheel==0.24.0
wsgiref==0.1.2

I do not understand this traceback and how to handle this....我不明白这个回溯以及如何处理这个......

Maybe because at the beginning I tried to install dependencies using file getting from Server not being in vertualenv.. And some traces remain in cache, but when I clean cache of pip nothing changes.也许是因为一开始我尝试使用从服务器获取的文件不在 vertualenv 中安装依赖项。并且一些痕迹保留在缓存中,但是当我清理 pip 的缓存时没有任何变化。

So what is the problem here and how to handle it?那么这里的问题是什么以及如何处理呢?

Thanks in advance!提前致谢!

EDIT ONE:编辑一:

The problem is that RPI.gpio is only for linux machine (for Raspberry Pi to be more exact) and I am trying to install it on Windows.问题是 RPI.gpio 仅适用于 linux 机器(更准确地说是 Raspberry Pi),我正在尝试将它安装在 Windows 上。

So should I somehow to clean /tmp or cache...?那么我应该以某种方式清理 /tmp 或缓存...?

在您的情况下,有些软件包在 Windows 中无法编译。在 Raspberry Pi 中创建一个 virtualenv,将所有软件包安装在那里。然后从 Raspberry Pi 复制 site-packages 文件夹并将其粘贴到 windows 上的 Site-Packages 目录中。这应该可以工作。

There is easy way in your case as I can see.如我所见,在您的情况下有一种简单的方法。 You have implemented some packages which is not capable for running on Windows machine, like RpiGpio.你已经实现了一些不能在 Windows 机器上运行的包,比如 RpiGpio。 So just remove them from your requirements list and get it done.因此,只需将它们从您的需求列表中删除并完成即可。

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

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