Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

pip install fails with Python 3.7 #132

Open
ghost opened this issue Sep 5, 2018 · 11 comments
Open

pip install fails with Python 3.7 #132

ghost opened this issue Sep 5, 2018 · 11 comments
Labels
being considered Actively being investigated by maintainers for merging

Comments

@ghost
Copy link

ghost commented Sep 5, 2018

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
Copy link
Author

ghost commented Sep 5, 2018

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 

@YuMan-Tam
Copy link

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

@matrixise
Copy link

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

@Finistere
Copy link

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

@doanguyen
Copy link

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

@kfrncs
Copy link

kfrncs commented Jan 8, 2019

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

@caethan caethan added the being considered Actively being investigated by maintainers for merging label Feb 8, 2019
@balodja
Copy link

balodja commented Feb 13, 2019

Same issue here. Thanks for the workaround.

@leolchat
Copy link

+1

yssource added a commit to yssource/rqalpha that referenced this issue May 27, 2019
andreas-h pushed a commit to andreas-h/line_profiler-feedstock that referenced this issue May 31, 2019
Upstream problem is documented in rkern/line_profiler#132, but
upstream seems unresponsive.

This here tries to implement the fix suggested in the upstream issue
by manually running Cython before pip installing.

closes conda-forge#20
@erezaei
Copy link

erezaei commented Jun 14, 2019

What if I don't have it?

@boeddeker
Copy link

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:

line_profiler/setup.py

Lines 12 to 25 in 3cdc2fa

try:
from Cython.Distutils import build_ext
cmdclass = dict(build_ext=build_ext)
line_profiler_source = '_line_profiler.pyx'
except ImportError:
cmdclass = {}
line_profiler_source = '_line_profiler.c'
if not os.path.exists(line_profiler_source):
raise distutils.errors.DistutilsError("""\
You need Cython to build the line_profiler from a git checkout, or
alternatively use a release tarball from PyPI to build it without Cython.""")
else:
warn("Could not import Cython. "
"Using the available pre-generated C file.")

@chuaxr
Copy link

chuaxr commented Dec 26, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
being considered Actively being investigated by maintainers for merging
Projects
None yet
Development

No branches or pull requests