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

'pip install' fails but different from #132 and #127 #133

Open
matjojo opened this issue Sep 18, 2018 · 5 comments
Open

'pip install' fails but different from #132 and #127 #133

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

Comments

@matjojo
Copy link

matjojo commented Sep 18, 2018

On windows 10, python: Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32

pip install gives:

C:\windows\system32>pip install line_profiler
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 c:\program files\python37\lib\site-packages (from line_profiler) (6.5.0)
Requirement already satisfied: setuptools>=18.5 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (39.0.1)
Requirement already satisfied: colorama; sys_platform == "win32" in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (0.3.9)
Requirement already satisfied: pickleshare in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (0.7.4)
Requirement already satisfied: backcall in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (0.1.0)
Requirement already satisfied: jedi>=0.10 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (0.12.1)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.15 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (1.0.15)
Requirement already satisfied: simplegeneric>0.8 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (0.8.1)
Requirement already satisfied: decorator in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (4.3.0)
Requirement already satisfied: traitlets>=4.2 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (4.3.2)
Requirement already satisfied: pygments in c:\program files\python37\lib\site-packages (from IPython>=0.13->line_profiler) (2.2.0)
Requirement already satisfied: parso>=0.3.0 in c:\program files\python37\lib\site-packages (from jedi>=0.10->IPython>=0.13->line_profiler) (0.3.1)
Requirement already satisfied: six>=1.9.0 in c:\program files\python37\lib\site-packages (from prompt-toolkit<2.0.0,>=1.0.15->IPython>=0.13->line_profiler) (1.11.0)
Requirement already satisfied: wcwidth in c:\program files\python37\lib\site-packages (from prompt-toolkit<2.0.0,>=1.0.15->IPython>=0.13->line_profiler) (0.1.7)
Requirement already satisfied: ipython-genutils in c:\program files\python37\lib\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 "c:\program files\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\matth\\AppData\\Local\\Temp\\pip-install-vbo2eo4l\\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 C:\Users\matth\AppData\Local\Temp\pip-record-rn3bjfgm\install-record.txt --single-version-externally-managed --compile:
    Could not import Cython. Using the available pre-generated C file.
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    copying line_profiler.py -> build\lib.win-amd64-3.7
    copying kernprof.py -> build\lib.win-amd64-3.7
    copying line_profiler_py35.py -> build\lib.win-amd64-3.7
    running build_ext
    building '_line_profiler' extension
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-Ic:\program files\python37\include" "-Ic:\program files\python37\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tc_line_profiler.c /Fobuild\temp.win-amd64-3.7\Release\_line_profiler.obj
    _line_profiler.c
    _line_profiler.c(7890): error C2039: 'exc_type': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7891): error C2039: 'exc_value': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7892): error C2039: 'exc_traceback': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7899): error C2039: 'exc_type': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7900): error C2039: 'exc_value': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7901): error C2039: 'exc_traceback': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7902): error C2039: 'exc_type': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7903): error C2039: 'exc_value': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7904): error C2039: 'exc_traceback': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7959): error C2039: 'exc_type': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7960): error C2039: 'exc_value': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7961): error C2039: 'exc_traceback': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7962): error C2039: 'exc_type': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7963): error C2039: 'exc_value': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    _line_profiler.c(7964): error C2039: 'exc_traceback': is not a member of '_ts'
    c:\program files\python37\include\pystate.h(209): note: see declaration of '_ts'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command ""c:\program files\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\matth\\AppData\\Local\\Temp\\pip-install-vbo2eo4l\\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 C:\Users\matth\AppData\Local\Temp\pip-record-rn3bjfgm\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\matth\AppData\Local\Temp\pip-install-vbo2eo4l\line-profiler\

C:\windows\system32>

(It says requirement already satisfied for all requirements because I already tried this before but I had to install vs build tools. Thus it had already installed all the requirements. )
I tried this #132 (comment) :

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

This fails with:

C:\windows\system32>git clone https://github.com/rkern/line_profiler.git
Cloning into 'line_profiler'...
remote: Counting objects: 344, done.
Receiving objects:  97% (334/344)   0 (delta 0), pack-reused 344
Receiving objects: 100% (344/344), 153.10 KiB | 637.00 KiB/s, done.
Resolving deltas: 100% (164/164), done.

C:\windows\system32>find line_profiler -name '*.pyx' -exec cython {} \;
File not found - '*.pyx'

This last command made me feel like it failed already but I also executed the last command:


C:\windows\system32>cd line_profiler && pip install . --user
Processing c:\windows\system32\line_profiler
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "C:\Users\matth\AppData\Local\Temp\pip-req-build-lyql0su9\setup.py", line 13, in <module>
        from Cython.Distutils import build_ext
    ModuleNotFoundError: No module named 'Cython'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\matth\AppData\Local\Temp\pip-req-build-lyql0su9\setup.py", line 22, in <module>
        alternatively use a release tarball from PyPI to build it without Cython.""")
    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.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\matth\AppData\Local\Temp\pip-req-build-lyql0su9\

From #127 (comment) I tried:

pip install Cython git+https://github.com/rkern/line_profiler.git

it gives:

C:\Windows\System32>pip install Cython git+https://github.com/rkern/line_profiler.git
Collecting git+https://github.com/rkern/line_profiler.git
  Cloning https://github.com/rkern/line_profiler.git to c:\users\matth\appdata\local\temp\pip-req-build-pvpd8a0e
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "C:\Users\matth\AppData\Local\Temp\pip-req-build-pvpd8a0e\setup.py", line 13, in <module>
        from Cython.Distutils import build_ext
    ModuleNotFoundError: No module named 'Cython'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\matth\AppData\Local\Temp\pip-req-build-pvpd8a0e\setup.py", line 22, in <module>
        alternatively use a release tarball from PyPI to build it without Cython.""")
    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.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\matth\AppData\Local\Temp\pip-req-build-pvpd8a0e\

C:\Windows\System32>

These two errors make it look like I need to install cython, but after pip install cython which returned succesfully:

Collecting cython
  Downloading https://files.pythonhosted.org/packages/e4/eb/8e28b1d38e6efbc3f20913b21332673e63d60d2db641de2536e94cebfbb4/Cython-0.28.5-cp37-cp37m-win_amd64.whl (2.5MB)
    100% |████████████████████████████████| 2.5MB 3.4MB/s
Installing collected packages: cython
Successfully installed cython-0.28.5

executing pip install line_profiler still fails with the same error as above.

@choosehappy
Copy link

same here

@choosehappy
Copy link

update: although i got the same error as you, i used the fix in #132 and things worked out

looks like you're not in the right directory when you run cython (and there is only a single file necessary to be computed).

this worked for me:
C:\tmnpo\line_profiler>cython _line_profiler.pyx

@matjojo
Copy link
Author

matjojo commented Oct 4, 2018

With @choosehappy 's thought I was able to get this to work. The solution (for windows) is this.

open git-bash in the folder you want line_profiler to copy to. 
pip install cython
git clone https://github.com/rkern/line_profiler.git
got into the newly cloned folder
cython line_profiler
pip install . --user

It's a combination of both methods, and pip successfully installed line_profiler with this.


matth@DESKTOP-JOODKLV MINGW64 /c/Programming/pipinstalltryout/line_profiler (master)
$ pip install . --user
Processing c:\programming\pipinstalltryout\line_profiler
Requirement already satisfied: IPython>=0.13 in c:\program files\python37\lib\site-packages (from line-profiler==2.1.1) (6.5.0)
Requirement already satisfied: simplegeneric>0.8 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.8.1)
Requirement already satisfied: setuptools>=18.5 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (39.0.1)
Requirement already satisfied: pickleshare in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.7.4)
Requirement already satisfied: traitlets>=4.2 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (4.3.2)
Requirement already satisfied: colorama; sys_platform == "win32" in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.3.9)
Requirement already satisfied: backcall in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.1.0)
Requirement already satisfied: decorator in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (4.3.0)
Requirement already satisfied: pygments in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (2.2.0)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.15 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (1.0.15)
Requirement already satisfied: jedi>=0.10 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.12.1)
Requirement already satisfied: six in c:\program files\python37\lib\site-packages (from traitlets>=4.2->IPython>=0.13->line-profiler==2.1.1) (1.11.0)
Requirement already satisfied: ipython-genutils in c:\program files\python37\lib\site-packages (from traitlets>=4.2->IPython>=0.13->line-profiler==2.1.1) (0.2.0)
Requirement already satisfied: wcwidth in c:\program files\python37\lib\site-packages (from prompt-toolkit<2.0.0,>=1.0.15->IPython>=0.13->line-profiler==2.1.1) (0.1.7)
Requirement already satisfied: parso>=0.3.0 in c:\program files\python37\lib\site-packages (from jedi>=0.10->IPython>=0.13->line-profiler==2.1.1) (0.3.1)
Installing collected packages: line-profiler
  Running setup.py install for line-profiler: started
    Running setup.py install for line-profiler: finished with status 'done'
Successfully installed line-profiler-2.1.1

matth@DESKTOP-JOODKLV MINGW64 /c/Programming/pipinstalltryout/line_profiler (master)
$

The only problem is that I can't just call kernprof -l file.py now, since the kernprof.py file has not been added to the PATH environment variable. calling C:\path\to\file\kernprof.py does work, but it's a bit awkward. Leaving this issue open since the fix is not a pretty workaround and it doesn't get added to the path

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

@matjojo's solution also works for mac. Many thanks!

@dostabhi
Copy link

dostabhi commented Oct 25, 2019

With @choosehappy 's thought I was able to get this to work. The solution (for windows) is this.

open git-bash in the folder you want line_profiler to copy to. 
pip install cython
git clone https://github.com/rkern/line_profiler.git
got into the newly cloned folder
cython line_profiler
pip install . --user

It's a combination of both methods, and pip successfully installed line_profiler with this.


matth@DESKTOP-JOODKLV MINGW64 /c/Programming/pipinstalltryout/line_profiler (master)
$ pip install . --user
Processing c:\programming\pipinstalltryout\line_profiler
Requirement already satisfied: IPython>=0.13 in c:\program files\python37\lib\site-packages (from line-profiler==2.1.1) (6.5.0)
Requirement already satisfied: simplegeneric>0.8 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.8.1)
Requirement already satisfied: setuptools>=18.5 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (39.0.1)
Requirement already satisfied: pickleshare in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.7.4)
Requirement already satisfied: traitlets>=4.2 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (4.3.2)
Requirement already satisfied: colorama; sys_platform == "win32" in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.3.9)
Requirement already satisfied: backcall in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.1.0)
Requirement already satisfied: decorator in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (4.3.0)
Requirement already satisfied: pygments in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (2.2.0)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.15 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (1.0.15)
Requirement already satisfied: jedi>=0.10 in c:\program files\python37\lib\site-packages (from IPython>=0.13->line-profiler==2.1.1) (0.12.1)
Requirement already satisfied: six in c:\program files\python37\lib\site-packages (from traitlets>=4.2->IPython>=0.13->line-profiler==2.1.1) (1.11.0)
Requirement already satisfied: ipython-genutils in c:\program files\python37\lib\site-packages (from traitlets>=4.2->IPython>=0.13->line-profiler==2.1.1) (0.2.0)
Requirement already satisfied: wcwidth in c:\program files\python37\lib\site-packages (from prompt-toolkit<2.0.0,>=1.0.15->IPython>=0.13->line-profiler==2.1.1) (0.1.7)
Requirement already satisfied: parso>=0.3.0 in c:\program files\python37\lib\site-packages (from jedi>=0.10->IPython>=0.13->line-profiler==2.1.1) (0.3.1)
Installing collected packages: line-profiler
  Running setup.py install for line-profiler: started
    Running setup.py install for line-profiler: finished with status 'done'
Successfully installed line-profiler-2.1.1

matth@DESKTOP-JOODKLV MINGW64 /c/Programming/pipinstalltryout/line_profiler (master)
$

The only problem is that I can't just call kernprof -l file.py now, since the kernprof.py file has not been added to the PATH environment variable. calling C:\path\to\file\kernprof.py does work, but it's a bit awkward. Leaving this issue open since the fix is not a pretty workaround and it doesn't get added to the path

The following works:
python "C:/path/to/line_profiler/kernprof.py" -l -v script.py

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

5 participants