line_profiler icon indicating copy to clipboard operation
line_profiler copied to clipboard

`pip install` fails with Python 3.7

Open ghost opened this issue 5 years ago • 11 comments

Unable to install with python3.7.

$ pip install line_profiler --user
Collecting line_profiler
  Using cached https://files.pythonhosted.org/packages/14/fc/ecf4e238bb601ff829068e5a72cd1bd67b0ee0ae379db172eb6a0779c6b6/line_profiler-2.1.2.tar.gz
Requirement already satisfied: IPython>=0.13 in /home/taha/.local/lib/python3.7/site-packages (from line_profiler) (6.5.0)
Requirement already satisfied: pexpect; sys_platform != "win32" in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (4.6.0)
Requirement already satisfied: pickleshare in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (0.7.4)
Requirement already satisfied: jedi>=0.10 in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (0.12.1)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.15 in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (1.0.15)
Requirement already satisfied: setuptools>=18.5 in /usr/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (40.2.0)
Requirement already satisfied: pygments in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (2.2.0)
Requirement already satisfied: traitlets>=4.2 in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (4.3.2)
Requirement already satisfied: backcall in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (0.1.0)
Requirement already satisfied: decorator in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (4.3.0)
Requirement already satisfied: simplegeneric>0.8 in /home/taha/.local/lib/python3.7/site-packages (from IPython>=0.13->line_profiler) (0.8.1)
Requirement already satisfied: ptyprocess>=0.5 in /home/taha/.local/lib/python3.7/site-packages (from pexpect; sys_platform != "win32"->IPython>=0.13->line_profiler) (0.6.0)
Requirement already satisfied: parso>=0.3.0 in /home/taha/.local/lib/python3.7/site-packages (from jedi>=0.10->IPython>=0.13->line_profiler) (0.3.1)
Requirement already satisfied: wcwidth in /home/taha/.local/lib/python3.7/site-packages (from prompt-toolkit<2.0.0,>=1.0.15->IPython>=0.13->line_profiler) (0.1.7)
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3.7/site-packages (from prompt-toolkit<2.0.0,>=1.0.15->IPython>=0.13->line_profiler) (1.11.0)
Requirement already satisfied: ipython-genutils in /home/taha/.local/lib/python3.7/site-packages (from traitlets>=4.2->IPython>=0.13->line_profiler) (0.2.0)
Installing collected packages: line-profiler
  Running setup.py install for line-profiler ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ob2zmt46/line-profiler/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-p1lprqxu/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    copying line_profiler.py -> build/lib.linux-x86_64-3.7
    copying kernprof.py -> build/lib.linux-x86_64-3.7
    copying line_profiler_py35.py -> build/lib.linux-x86_64-3.7
    running build_ext
    skipping '_line_profiler.c' Cython extension (up-to-date)
    building '_line_profiler' extension
    creating build/temp.linux-x86_64-3.7
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fPIC -I/usr/include/python3.7m -c _line_profiler.c -o build/temp.linux-x86_64-3.7/_line_profiler.o
    _line_profiler.c: In function ‘__Pyx__ExceptionSave’:
    _line_profiler.c:7890:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
         *type = tstate->exc_type;
                         ^~~~~~~~
                         curexc_type
    _line_profiler.c:7891:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
         *value = tstate->exc_value;
                          ^~~~~~~~~
                          curexc_value
    _line_profiler.c:7892:19: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
         *tb = tstate->exc_traceback;
                       ^~~~~~~~~~~~~
                       curexc_traceback
    _line_profiler.c: In function ‘__Pyx__ExceptionReset’:
    _line_profiler.c:7899:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
         tmp_type = tstate->exc_type;
                            ^~~~~~~~
                            curexc_type
    _line_profiler.c:7900:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
         tmp_value = tstate->exc_value;
                             ^~~~~~~~~
                             curexc_value
    _line_profiler.c:7901:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
         tmp_tb = tstate->exc_traceback;
                          ^~~~~~~~~~~~~
                          curexc_traceback
    _line_profiler.c:7902:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
         tstate->exc_type = type;
                 ^~~~~~~~
                 curexc_type
    _line_profiler.c:7903:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
         tstate->exc_value = value;
                 ^~~~~~~~~
                 curexc_value
    _line_profiler.c:7904:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
         tstate->exc_traceback = tb;
                 ^~~~~~~~~~~~~
                 curexc_traceback
    _line_profiler.c: In function ‘__Pyx__GetException’:
    _line_profiler.c:7959:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
         tmp_type = tstate->exc_type;
                            ^~~~~~~~
                            curexc_type
    _line_profiler.c:7960:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
         tmp_value = tstate->exc_value;
                             ^~~~~~~~~
                             curexc_value
    _line_profiler.c:7961:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
         tmp_tb = tstate->exc_traceback;
                          ^~~~~~~~~~~~~
                          curexc_traceback
    _line_profiler.c:7962:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
         tstate->exc_type = local_type;
                 ^~~~~~~~
                 curexc_type
    _line_profiler.c:7963:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
         tstate->exc_value = local_value;
                 ^~~~~~~~~
                 curexc_value
    _line_profiler.c:7964:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
         tstate->exc_traceback = local_tb;
                 ^~~~~~~~~~~~~
                 curexc_traceback
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ob2zmt46/line-profiler/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-p1lprqxu/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-ob2zmt46/line-profiler/

ghost avatar Sep 05 '18 23:09 ghost

This is seems to be an issue with the precompiled *.c files being used instead of running cython over *.pyx. Here is a workaround:

git clone https://github.com/rkern/line_profiler.git
find line_profiler -name '*.pyx' -exec cython {} \;
cd line_profiler && pip install . --user 

tacotaha avatar Sep 05 '18 23:09 tacotaha

I encountered exactly the same problem. The solution works perfectly. Thank you!

YuMan-Tam avatar Sep 12 '18 00:09 YuMan-Tam

+1 for the fix, could you fix this issue. thank you

matrixise avatar Sep 20 '18 08:09 matrixise

Pandas and others had the same issue pandas-dev/pandas#21785. Could you please make a new release with the latest Cython ?

Finistere avatar Nov 01 '18 15:11 Finistere

The issue has been here for months but no patch yet, is someone going to put it on pypi?

doanguyen avatar Dec 11 '18 18:12 doanguyen

Also had this issue, also fixed by @tazzaoui 's comment. Thanks.

kfrncs avatar Jan 08 '19 19:01 kfrncs

Same issue here. Thanks for the workaround.

balodja avatar Feb 13 '19 11:02 balodja

+1

leolchat avatar Apr 23 '19 16:04 leolchat

What if I don't have it?

erezaei avatar Jun 14 '19 23:06 erezaei

For me, a direct install from github was also working: pip install git+https://github.com/rkern/line_profiler When Cython is installed, this should work, otherwise, the following may cause problems:

https://github.com/rkern/line_profiler/blob/3cdc2fab6793802d31130b1af2705bddebf6f7fd/setup.py#L12-L25

boeddeker avatar Dec 10 '19 15:12 boeddeker

I was using Ubuntu installed on windows and also needed to install gcc (via sudo apt install gcc) before the pip install git+.

chuaxr avatar Dec 26 '19 07:12 chuaxr