Python中的ujson包安装错误

Posted

技术标签:

【中文标题】Python中的ujson包安装错误【英文标题】:ujson Package Installation Error in Python 【发布时间】:2021-05-01 15:45:27 【问题描述】:

当我尝试在 Windows 10 上的 python 3.6 中安装 ujson 包时(安装 binance-python 库所需的)我收到此错误:

C:\Users\MHT\python_projects\crypto\env\Scripts
(env) λ pip install ujson
Collecting ujson
  Using cached ujson-4.0.2.tar.gz (7.1 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: ujson
  Building wheel for ujson (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\mht\python_projects\crypto\env\scripts\python.exe' 'c:\users\mht\python_projects\crypto\env\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\MHT\AppData\Local\Temp\tmpfwaht9wj'
       cwd: C:\Users\MHT\AppData\Local\Temp\pip-install-97ynb6ua\ujson_0cc2905684bb497985ff0e4ac258eafe
  Complete output (16 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'ujson' extension
  creating build
  creating build\temp.win32-3.6
  creating build\temp.win32-3.6\Release
  creating build\temp.win32-3.6\Release\deps
  creating build\temp.win32-3.6\Release\deps\double-conversion
  creating build\temp.win32-3.6\Release\deps\double-conversion\double-conversion
  creating build\temp.win32-3.6\Release\lib
  creating build\temp.win32-3.6\Release\python
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I./python -I./lib -I./deps/double-conversion/double-conversion -Ic:\users\mht\python_projects\crypto\env\include -Ic:\users\mht\appdata\local\programs\python\python36-32\include -Ic:\users\mht\appdata\local\programs\python\python36-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\include" /EHsc /Tp./deps/double-conversion/double-conversion\bignum-dtoa.cc /Fobuild\temp.win32-3.6\Release\./deps/double-conversion/double-conversion\bignum-dtoa.obj -D_GNU_SOURCE
  bignum-dtoa.cc
  ./deps/double-conversion/double-conversion\bignum-dtoa.cc(28): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for ujson
Failed to build ujson
ERROR: Could not build wheels for ujson which use PEP 517 and cannot be installed directly

我该如何解决这个问题?

【问题讨论】:

math.h 如果我没记错的话是一个基本的头文件,所以你可能需要安装某种 C/C++ 开发工具链。我不知道你到底需要什么工具链。 【参考方案1】:

尝试在此处安装 Visual Studio:https://visualstudio.microsoft.com/。通常,包依赖于 Visual Studio 的 C/C++ 编译器。

它似乎终止了,因为运行了以下命令:

error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

失败。安装 Visual Studio 应该可以解决这个问题。

【讨论】:

我之前安装了visual studio c++ v14+构建工具,但我帮不上忙 这是 Visual Studio 2019? 谢谢你,我再次使用 MVSC 构建工具重新安装了 Visual Studio c++ v14+,它解决了我的问题。

以上是关于Python中的ujson包安装错误的主要内容,如果未能解决你的问题,请参考以下文章

在 ubuntu 中安装 ujson 的问题

导入Universe

Pycharm 中的“未安装 Jupyter 包”错误消息(使用 Windows)。我该如何解决?

python包使用pip安装错误

python2.7使用pip安装包一直错误

python安装大型包时出现错误Unable to find vcvarsall.bat