0

I am trying to install the gwpy package in Ubuntu 20.04 and with Python 3.9

While successfully installed with below command for python 3.8 but can not make it work for Python 3.9

pip3 install gwpy

The above command successfully installs gwpy in directory /.local/lib/python3.8/site-packages and working good with Python 3.8

But when I am choosing Python 3.9 then gwpy module is not getting recognized and getting "ImportError: No module named gwpy"

Have tried below command for Python 3.9

python3.9 -m pip install

and also,

pip3.9 install gwpy

But get the same error (below)

( I already uninstalled and re-installed 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('"'"'\r\n'"'"', '"'"'\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('"'"'\r\n'"'"', '"'"'\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('"'"'\r\n'"'"', '"'"'\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.

I have already removed Python 3.9 completely and freshly re-installed it in my system.

Rohan_Paul
  • 1,504
  • 3
  • 29
  • 36

1 Answers1

0

Found the solution from the very helpful comment of @Sujay at the bottom of the question.

From this SO post

Just installed below

sudo apt-get install python3.9-dev
Rohan_Paul
  • 1,504
  • 3
  • 29
  • 36