但是当我选择Python 3.9时,
我正在尝试在Ubuntu 20.04和Python 3.9中安装gwpy包
使用以下命令成功安装python 3.8,但无法使其工作在python 3.9
pip3 install gwpy
上面的命令成功地将gwpy
安装到目录/.local/lib/python3.8/site-packages
中,并且在Python 3.8中运行良好
但是当我选择Python 3.9时,gwpy
模块没有被识别并获得" importterror:没有名为gwpy">
的模块已尝试Python 3.9
python3.9 -m pip install
,
pip3.9 install gwpy
但是得到相同的错误(下面)
(我已经卸载并重新安装了ligo-segments)
Building wheels for collected packages: ligo-segments
Building wheel for ligo-segments (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l_etxqfg/ligo-segments_093d6d7361fe403dba837e6e5793581f/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l_etxqfg/ligo-segments_093d6d7361fe403dba837e6e5793581f/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-m3l2cb3f
cwd: /tmp/pip-install-l_etxqfg/ligo-segments_093d6d7361fe403dba837e6e5793581f/
Complete output (20 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/ligo
copying ligo/__init__.py -> build/lib.linux-x86_64-3.9/ligo
creating build/lib.linux-x86_64-3.9/ligo/segments
copying ligo/segments/utils.py -> build/lib.linux-x86_64-3.9/ligo/segments
copying ligo/segments/__init__.py -> build/lib.linux-x86_64-3.9/ligo/segments
running build_ext
building 'ligo.segments.__segments' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/src
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 -Isrc -I/usr/include/python3.9 -c src/infinity.c -o build/temp.linux-x86_64-3.9/src/infinity.o
src/infinity.c:29:10: fatal error: Python.h: No such file or directory
29 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for ligo-segments
Running setup.py clean for ligo-segments
Failed to build ligo-segments
Installing collected packages: ligo-segments, pyerfa, gwdatafind, tqdm, ligotimegps, h5py, gwosc, dqsegdb2, astropy, gwpy
Running setup.py install for ligo-segments ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l_etxqfg/ligo-segments_093d6d7361fe403dba837e6e5793581f/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l_etxqfg/ligo-segments_093d6d7361fe403dba837e6e5793581f/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7g5qg2rc/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/paul/.local/include/python3.9/ligo-segments
cwd: /tmp/pip-install-l_etxqfg/ligo-segments_093d6d7361fe403dba837e6e5793581f/
Complete output (20 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/ligo
copying ligo/__init__.py -> build/lib.linux-x86_64-3.9/ligo
creating build/lib.linux-x86_64-3.9/ligo/segments
copying ligo/segments/utils.py -> build/lib.linux-x86_64-3.9/ligo/segments
copying ligo/segments/__init__.py -> build/lib.linux-x86_64-3.9/ligo/segments
running build_ext
building 'ligo.segments.__segments' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/src
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 -Isrc -I/usr/include/python3.9 -c src/infinity.c -o build/temp.linux-x86_64-3.9/src/infinity.o
src/infinity.c:29:10: fatal error: Python.h: No such file or directory
29 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l_etxqfg/ligo-segments_093d6d7361fe403dba837e6e5793581f/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l_etxqfg/ligo-segments_093d6d7361fe403dba837e6e5793581f/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7g5qg2rc/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/paul/.local/include/python3.9/ligo-segments Check the logs for full command output.
我已经完全删除了Python 3.9并在我的系统中重新安装了它。
从@Sujay在问题下方非常有帮助的评论中找到了解决方案。
From this SO post
刚安装在
下面sudo apt-get install python3.9-dev