在 ubuntu 中安装 ujson 的问题
Posted
技术标签:
【中文标题】在 ubuntu 中安装 ujson 的问题【英文标题】:Issue in installing ujson in ubuntu 【发布时间】:2020-05-27 01:55:51 【问题描述】:我正在尝试安装 ujson,这是安装 RASA 所需的依赖项。我触发的命令如下:
sudo pip3 install ujson
并收到以下错误消息。
WARNING: The directory '/home/kamaldeep/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting ujson
Downloading ujson-1.35.tar.gz (192 kB)
|████████████████████████████████| 192 kB 217 kB/s
Building wheels for collected packages: ujson
Building wheel for ujson (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uo5b9gzb/ujson/setup.py'"'"'; _file__='"'"'/tmp/pip-install-uo5b9gzb/ujson/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 /tmp/pip-wheel-918warx5
cwd: /tmp/pip-install-uo5b9gzb/ujson/
Complete output (14 lines):
Warning: 'classifiers' should be a list, got type 'filter'
running bdist_wheel
running build
running build_ext
building 'ujson' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/python
creating build/temp.linux-x86_64-3.7/lib
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./python -I./lib -I/usr/include/python3.7m -c ./python/ujson.c -o build/temp.linux-x86_64-3.7/./python/ujson.o -D_GNU_SOURCE
In file included from ./python/ujson.c:39:0:
./python/py_defines.h:39:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for ujson
Running setup.py clean for ujson
Failed to build ujson
Installing collected packages: ujson
Running setup.py install for ujson ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uo5b9gzb/ujson/setup.py'"'"'; _file__='"'"'/tmp/pip-install-uo5b9gzb/ujson/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, _file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-c2p8ewru/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/ujson
cwd: /tmp/pip-install-uo5b9gzb/ujson/
Complete output (14 lines):
Warning: 'classifiers' should be a list, got type 'filter'
running install
running build
running build_ext
building 'ujson' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/python
creating build/temp.linux-x86_64-3.7/lib
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./python -I./lib -I/usr/include/python3.7m -c ./python/ujson.c -o build/temp.linux-x86_64-3.7/./python/ujson.o -D_GNU_SOURCE
In file included from ./python/ujson.c:39:0:
./python/py_defines.h:39:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uo5b9gzb/ujson/setup.py'"'"'; _file__='"'"'/tmp/pip-install-uo5b9gzb/ujson/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, _file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-c2p8ewru/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/ujson Check the logs for full command output.
enter image description here
请告诉我解决方案。提前致谢。
【问题讨论】:
这能回答你的问题吗? fatal error: Python.h: No such file or directory 【参考方案1】:您需要安装 python 开发包,因为您是从源代码构建模块。
sudo aptitude install python-dev
【讨论】:
【参考方案2】:超级简单!
sudo apt-get update
sudo apt-get install python3-ujson
【讨论】:
以上是关于在 ubuntu 中安装 ujson 的问题的主要内容,如果未能解决你的问题,请参考以下文章
在Ubuntu中安装CodeCheckerNodeNVM:过程与排雷