我对 python 有 pip 陌生,我正在使用 pip 通过控制台安装软件包。与以前的安装配合得很好,但是当我尝试安装 pyzmq 时,我收到一条错误消息。我认为问题与 Cython 有关(因为我以前见过类似的东西),但后来我安装了 Cython,问题仍然存在。这是我收到的完整消息:
Collecting pyzmq
Using cached https://files.pythonhosted.org/packages/7a/d2/1eb3a994374802b352d4911f3317313a5b4ea786bc830cc5e343dad9b06d/pyzmq-18.1.0.tar.gz
Building wheels for collected packages: pyzmq
Building wheel for pyzmq (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\gianf\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\gianf\\AppData\\Local\\Temp\\pip-install-7scmlplo\\pyzmq\\setup.py'"'"'; __file__='"'"'C:\\Users\\gianf\\AppData\\Local\\Temp\\pip-install-7scmlplo\\pyzmq\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\gianf\AppData\Local\Temp\pip-wheel-hxgsq9q7' --python-tag cp38
cwd: C:\Users\gianf\AppData\Local\Temp\pip-install-7scmlplo\pyzmq\
Complete output (191 lines):
running bdist_wheel
running build
running build_py
Generating grammar tables from C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\lib\lib2to3\Grammar.txt
Writing grammar tables to C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\lib\lib2to3\Grammar3.8.0.final.0.pickle
Writing failed: [Errno 13] Permission denied: 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\\lib\\lib2to3\\Grammar3.8.0.final.0.pickle'
Generating grammar tables from C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\lib\lib2to3\PatternGrammar.txt
Writing grammar tables to C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\lib\lib2to3\PatternGrammar3.8.0.final.0.pickle
Writing failed: [Errno 13] Permission denied: 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\\lib\\lib2to3\\PatternGrammar3.8.0.final.0.pickle'
creating build
(((copying / creating a bunch of stuff I omitted to fit on the post)))
copying zmq\utils\zmq_constants.h -> build\lib.win-amd64-3.8\zmq\utils
running build_ext
running configure
{'libraries': ['libzmq'], 'include_dirs': [], 'library_dirs': [], 'runtime_library_dirs': [], 'extra_link_args': []}
Warning: Couldn't find an acceptable libzmq on the system.
If you expected pyzmq to link against an installed libzmq, please check to make sure:
* You have a C compiler installed
* A development version of Python is installed (including headers)
* A development version of ZMQ >= 3.2 is installed (including headers)
* If ZMQ is not in a default location, supply the argument --zmq=<path>
* If you did recently install ZMQ to a default location,
try rebuilding the ld cache with `sudo ldconfig`
or specify zmq's location with `--zmq=/usr/local`
You can skip all this detection/waiting nonsense if you know
you want pyzmq to bundle libzmq as an extension by passing:
`--zmq=bundled`
I will now try to build libzmq as a Python extension
unless you interrupt me (^C) in the next 10 seconds...
************************************************
1...
Using bundled libzmq
already have bundled\zeromq
staging platform.hpp from: C:\Users\gianf\AppData\Local\Temp\pip-install-7scmlplo\pyzmq\buildutils\include_win32
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
************************************************
----------------------------------------
ERROR: Failed building wheel for pyzmq
Running setup.py clean for pyzmq
Failed to build pyzmq
Installing collected packages: pyzmq
Running setup.py install for pyzmq ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\gianf\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\gianf\\AppData\\Local\\Temp\\pip-install-7scmlplo\\pyzmq\\setup.py'"'"'; __file__='"'"'C:\\Users\\gianf\\AppData\\Local\\Temp\\pip-install-7scmlplo\\pyzmq\\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\gianf\AppData\Local\Temp\pip-record-7kjkoe_6\install-record.txt' --single-version-externally-managed --compile --user --prefix=
cwd: C:\Users\gianf\AppData\Local\Temp\pip-install-7scmlplo\pyzmq\
Complete output (193 lines):
running install
running build
running build_py
Generating grammar tables from C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\lib\lib2to3\Grammar.txt
Writing grammar tables to C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\lib\lib2to3\Grammar3.8.0.final.0.pickle
Writing failed: [Errno 13] Permission denied: 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\\lib\\lib2to3\\Grammar3.8.0.final.0.pickle'
Generating grammar tables from C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\lib\lib2to3\PatternGrammar.txt
Writing grammar tables to C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\lib\lib2to3\PatternGrammar3.8.0.final.0.pickle
Writing failed: [Errno 13] Permission denied: 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\\lib\\lib2to3\\PatternGrammar3.8.0.final.0.pickle'
(((copying / creating a bunch of lines I omitted to fit on the post)))
running build_ext
running configure
{'libraries': ['libzmq'], 'include_dirs': [], 'library_dirs': [], 'runtime_library_dirs': [], 'extra_link_args': []}
Warning: Couldn't find an acceptable libzmq on the system.
If you expected pyzmq to link against an installed libzmq, please check to make sure:
* You have a C compiler installed
* A development version of Python is installed (including headers)
* A development version of ZMQ >= 3.2 is installed (including headers)
* If ZMQ is not in a default location, supply the argument --zmq=<path>
* If you did recently install ZMQ to a default location,
try rebuilding the ld cache with `sudo ldconfig`
or specify zmq's location with `--zmq=/usr/local`
You can skip all this detection/waiting nonsense if you know
you want pyzmq to bundle libzmq as an extension by passing:
`--zmq=bundled`
I will now try to build libzmq as a Python extension
unless you interrupt me (^C) in the next 10 seconds...
1...
Using bundled libzmq
already have bundled\zeromq
already have platform.hpp
building 'zmq.libzmq' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\gianf\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\gianf\\AppData\\Local\\Temp\\pip-install-7scmlplo\\pyzmq\\setup.py'"'"'; __file__='"'"'C:\\Users\\gianf\\AppData\\Local\\Temp\\pip-install-7scmlplo\\pyzmq\\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\gianf\AppData\Local\Temp\pip-record-7kjkoe_6\install-record.txt' --single-version-externally-managed --compile --user --prefix= Check the logs for full command output.
由于我注意到有关 MS C++ 的错误,因此我下载并安装了基本上与 Microsoft Visual C++ 相关的所有内容,但错误仍然存在。
还尝试通过msi文件安装pyzmq,但我不确定正确的路径。
最佳答案
我明白了!
我安装了 Visual Studio,但这还不够。我也需要构建工具,更具体地说,安装过程中可选包上带有“C++”的所有东西。之后我就可以毫无问题地安装软件包了。
关于python - 使用 pip 在 Windows 中安装 ZeroMQ/pyzmq 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58635139/