在Visual Studio的Python中,我可以安装软件包,据我所知,它不需要C源代码编译。对于需要编译的软件包,它总是会失败。我的安装尝试始终通过Visual Studio中的pip install package-name
完成。这就是我的尝试:
具体来说,我已尝试安装RPIO
和RPi.GPIO
,或多或少会出现类似的错误消息:
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
以下是RPIO
安装尝试的完整日志:
----- Installing 'RPIO==0.10.0' -----
Collecting RPIO==0.10.0
Using cached RPIO-0.10.0.tar.gz
Installing collected packages: RPIO
Running setup.py install for RPIO: started
Running setup.py install for RPIO: finished with status 'error'
Complete output from command "C:\Program Files\Python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\ELEMEN~1\\AppData\\Local\\Temp\\pip-build-4lvb_8wu\\RPIO\\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\ELEMEN~1\AppData\Local\Temp\pip-oqz8bi8d-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\RPIO
copying source\RPIO\Exceptions.py -build\lib.win-amd64-3.6\RPIO
copying source\RPIO\_RPIO.py -build\lib.win-amd64-3.6\RPIO
copying source\RPIO\__init__.py -build\lib.win-amd64-3.6\RPIO
creating build\lib.win-amd64-3.6\RPIO\PWM
copying source\RPIO\PWM\__init__.py -build\lib.win-amd64-3.6\RPIO\PWM
running build_ext
building 'RPIO._GPIO' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\source
creating build\temp.win-amd64-3.6\Release\source\c_gpio
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files\Python36\include" "-IC:\Program Files\Python36\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt" /Tcsource/c_gpio/py_gpio.c /Fobuild\temp.win-amd64-3.6\Release\source/c_gpio/py_gpio.obj
py_gpio.c
source/c_gpio/py_gpio.c(361): error C2373: 'setmode': redefinition; different type modifiers
C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt\corecrt_io.h(528): note: see declaration of 'setmode'
source/c_gpio/py_gpio.c(431): warning C4028: formal parameter 1 different from declaration
source/c_gpio/py_gpio.c(431): warning C4028: formal parameter 2 different from declaration
source/c_gpio/py_gpio.c(431): warning C4047: 'initializing': 'PyCFunction' differs in levels of indirection from 'int (__cdecl *)(int,int)'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
Command ""C:\Program Files\Python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\ELEMEN~1\\AppData\\Local\\Temp\\pip-build-4lvb_8wu\\RPIO\\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\ELEMEN~1\AppData\Local\Temp\pip-oqz8bi8d-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ELEMEN~1\AppData\Local\Temp\pip-build-4lvb_8wu\RPIO\
----- Failed to install 'RPIO==0.10.0' -----
所以我错过了什么?或者包装的来源是否遗漏了什么?
谢谢
答案 0 :(得分:0)
首先,谢谢你@martineau暗示问题
这不是一个完整的解决方案,而是一些解决方法。
<强> 1。使用另一个IDE /工具
虽然该库仍然与Windows工具链不兼容,但您可以尝试使用其他工具或IDE。
<强> 2。另一个图书馆
这是我采取的解决方法。基本上,我需要Python库来访问RPi GPIO,所谓的RPi.GPIO
和RPIO
不会安装在Windows ver上。 Python,所以我移动到另一个名为gpiozero
的库。它与Windows Python兼容(它在VS中成功pip
- 并且到目前为止提供了我需要的功能。
答案 1 :(得分:0)
看起来py_gpio.c
重新定义 setmode
(第361行,第431行使用)。这是他们代码中的错误,因此您应该找到拥有它的团队并向他们报告。很可能他们将其添加到支持旧版本的MSVC,并且不应该为当前版本添加它。
似乎代码使用的定义与C运行时的定义不同,如果变量类型不匹配,以后可能会导致问题。这里可能需要完整的代码审查。
在任何情况下,这似乎是RPi.GPIO
包的问题,而不是您的安装或您使用的工具。