As a new version of Visual Studio comes out, there are often fixes to put in your build chain tools so packages with external C/C++ compilation requirements still work. For Python 3.6 and Visual Studio 2017 to work together, a good reference start point is the Windows compilers compatibility list on python.org.
Let’s try to compile scrapy which has a lot of dependencies including the twisted package.
Let’s assume you have installed “Visual Studio 2017 Community” on your PC with the C++ support. Trying to run the well-known
1 |
pip install scrapy |
will end-up with a compile error, such as the following:
1 2 3 4 5 6 |
" building 'twisted.test.raiser' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools ---------------------------------------- Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-68oh6ofn\\Twisted\\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\ADMINI~1\AppData\Local\Temp\pip-paytsys9-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users \ADMINI~1\AppData\Local\Temp\pip-build-68oh6ofn\Twisted\" |
When working with Python 3.6 you may find however many stackoverflow articles stating that you must install Visual Studio 2015 back. Save yourself time and space by not doing it.
As mentioned as a requirement in the previously mentioned article, one requirement is to have a version of the setuptools library which is higher than 34.0. Unfortunately, Python 3.6 comes with 28.0 and the simple
1 |
pip install setuptools |
won’t work as it tells you you have already what’s needed. Use instead:
1 |
python -m pip install -U pip setuptools |
If everything goes well, you’ll have:
This will allow Python to access your Visual Studio 2017 installation and no longer have two versions or more installed in parallel.
The last trick is to use the proper environment to run command-line installations. With Visual Studio 2017 come multiple command prompts setups:
Do not choose ‘Developer’ although it may sound appealing. You’ll get caught with LNK2010 linking errors because of INCLUDE issues, in the same way that a regular cmd would output the following error:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DWIN32=1 "-Ic:\program files\python36\include" "-Ic:\program files\python36\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.1 0.25017\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\ATLMFC\Include" "-IC:\Program Files (x86)\Windows Ki ts\10\include\10.0.15063.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /Tcsrc/twisted/test/raiser.c /Fobuild\temp.win-amd64-3.6\Rele ase\src/twisted/test/raiser.obj raiser.c c:\program files\python36\include\pyconfig.h(222): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.10.25017\\bin\\HostX64\\x64\\cl.exe' failed with exit status 2 Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-amp2cfl7\\Twisted\\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\ADMINI~1\AppData\Local\Temp\pip-5lwfhlfl-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users \ADMINI~1\AppData\Local\Temp\pip-build-amp2cfl7\Twisted\ |
For proper compilation, choose the native architecture. In my case, I Choose ‘x64 Native Tools’ and finally got the following successful result:
Wow! Thank you very much, it really helped me!
Thank you very much! Like a lot!!
I couldn’t be bothered to download a humongous 4GB redundant older version c++ build tools, when I already have the latest ones.
I tried searching for steps to make python choose the latest vs version for the build, but there were no relevant solutions. This one worked as a charm 🙂
Thank you very much. You made my day!
Thank you very much for your solution. Worked perfectly! I did have to run the Command Prompt as administrator because I got an access denied error for read/write operations. Right mouse click Command Prompt as select: Run as administrator.
Dear Dimitri,
What command did you run in x64 native tools? Sorry for the silly question.
Thank you for your answer in advance!
All the pip install xxx commands I launched, such as pip install scrap outlined at the beginning of the post
Thanks a lot it save my life.
Dimitri, man, thank you so much for the solution! 1 minute updating setuptools vs half a day downloading yet another version of MS monstrocity is quite a difference.
Hello Dimitri. I failed to do the last trick. Can’t understand how could I run x64 Native Tools Command Prompt for VS 2017. I have only “Developer command prompt for VS 2017” available. Should I install something to have such a option?
Hello, in the version I installed, I’ve got 4 shortcut links under C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools\VC
The shortcut I’m talking about is running “%comspec% /k “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat”
If you look into the that folder, do you have this vcvars64.bat? And is the Developer Command Prompt point to it?
I’m wondering if the shortcut name changes with the Visual Studio releases or Edition…
Hey,
Even after trying the steps you mentioned, it’s giving the same error at my end. I also do not see the “Build” folder in the path below:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
which you have mentioned in the comment above!. What should I do in such a case.
In the Visual Studio Installer, under Individual Components, you may want to verify if ‘VC++ 2017 v141 toolset (x86,x64)’ is installed. Also do you have the Windows 10 SDK installed or not?
Hello Dmitri
I am trying to install cvxpy package which has many dependencies like scrapy using pip and got the errors you have mentioned above.
So I have installed python -m pip install -U pip setuptools which is the first step and successfully done the step.
coming to the second step how can I choose x64 Native Tools. I am confused.
I have got 4 shortcut links in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools\VC
and I have got vcvars64.bat file in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
How to know Developer Command Prompt is pointing to it.
Since your question isn’t related to the Python usage from Visual Studio 2017, I made a separate post about manipulating Explorer shortcuts.
Thanks a lot!
However, after I did “python -m pip install -U pip setuptools” for my Python 3.6 and got “Successfully installed setuptools-38.5.1”, I still have this error:
error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”:
I am not sure my Path setting is correct though. I added to my Path the following:
C:\Program Files (x86)\Microsoft Visual Studio\2017;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\bin;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\bin\MSBuild;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0
Almost everything.
Any clue?
Thanks a lot!
As mentioned in one of my previous answers, the commands at the end are launched through the vcvars64.bat prompt, which among other things set the path, but also do a few other things. You may want to do your compilation from that command prompt to see if it is working there.
hi after the step “python -m pip install -U pip setuptools” , i’m still getting a lot of errors.
C:\Users\Narayana>pip install setuptools
Requirement already satisfied: setuptools in c:\program files\python36\lib\site-packages
C:\Users\Narayana>python -m pip install -U pip setuptools
Requirement already up-to-date: pip in c:\program files\python36\lib\site-packages
Collecting setuptools
Using cached setuptools-38.5.2-py2.py3-none-any.whl
Installing collected packages: setuptools
Found existing installation: setuptools 28.8.0
Uninstalling setuptools-28.8.0:
Exception:
Traceback (most recent call last):
File “C:\Program Files\Python36\lib\shutil.py”, line 544, in move
os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: ‘c:\\program files\\python36\\lib\\site-packages\\__pycache__\\easy_install.cpython-36.pyc’ -> ‘C:\\Users\\Narayana\\AppData\\Local\\Temp\\pip-icydqxih-uninstall\\program files\\python36\\lib\\site-packages\\__pycache__\\easy_install.cpython-36.pyc’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:\Program Files\Python36\lib\site-packages\pip\basecommand.py”, line 215, in main
status = self.run(options, args)
File “C:\Program Files\Python36\lib\site-packages\pip\commands\install.py”, line 342, in run
prefix=options.prefix_path,
File “C:\Program Files\Python36\lib\site-packages\pip\req\req_set.py”, line 778, in install
requirement.uninstall(auto_confirm=True)
File “C:\Program Files\Python36\lib\site-packages\pip\req\req_install.py”, line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File “C:\Program Files\Python36\lib\site-packages\pip\req\req_uninstall.py”, line 115, in remove
renames(path, new_path)
File “C:\Program Files\Python36\lib\site-packages\pip\utils\__init__.py”, line 267, in renames
shutil.move(old, new)
File “C:\Program Files\Python36\lib\shutil.py”, line 559, in move
os.unlink(src)
PermissionError: [WinError 5] Access is denied: ‘c:\\program files\\python36\\lib\\site-packages\\__pycache__\\easy_install.cpython-36.pyc’
C:\Users\Narayana>
please help regarding this issue
Hello, Your error is permission denied as marked on the latest line. You may want to double check you have enough rights when executing those commands (local administrator in an elevated prompt)
Hi, I opened Windows PowerShell as Admin. the command “python -m pip install -U pi setuptools” worked fine. it successfully updated the required ones. the 3rd part is not getting done. I opened x64 Native Tools as Admin but the commands are not going good. when i enter “pip install pyswisseph” i’m getting the error not able to link the visual studio.
swhgeo.obj : error LNK2001: unresolved external symbol strtok_r
build\lib.win-amd64-3.6\swisseph.cp36-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
error: command ‘C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x64\\link.exe’ failed with exit status 1120
—————————————-
Command “”c:\program files\python36\python.exe” -u -c “import setuptools, tokenize;__file__=’C:\\Users\\Narayana\\AppData\\Local\\Temp\\pip-build-zxnmxm6a\\pyswisseph\\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\Narayana\AppData\Local\Temp\pip-mi08v6hq-record\install-record.txt –single-version-externally-managed –compile” failed with error code 1 in C:\Users\Narayana\AppData\Local\Temp\pip-build-zxnmxm6a\pyswisseph\
Basically i’m trying to workout the first command in the site : https://libraries.io/github/charandas/drik-panchanga.
Your issue has nothing to do with the Python support anymore. You’re trying to compile C Code for which there’s a call to a function ‘strtrok_r’. strtok_r is not supported on the Windows platform. I would look into the source code of the package or contact the author to know which symbol should be defined to compile under Windows eventually: there’s probably a #define Win32 missing…
Hi, Thanks for the info. I contacted the author. He said it was done for Linux and he doesn’t know how to do it on Windows. I think maybe that is the problem. Thanks for the support.
OMG! thanks ever so much!! I never knew those launch icons were in there. I tried all the other approaches to no avail. Launching the X64 native as administrator and pip install line_profiler went PERFECT.
I love the interwebs. You always run into smart people out here that figured something out.
Cheers guys!
Super! Thank you. Do I still need teachers?:)
–Dee
I tried this method to install glpk but hasn’t worked. Any alternative suggestion? Thanks in advance.
I’ve haven’t attempted this one, but which kind of error messages do you get? At Compilation? At Linking?
Hi,
I am trying to install pyyawt (python 3.6.5 visual studio 2017) and it keeps raising this error:
Command “”C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe” -u -c “import setuptools, tokenize;__file__=’C:\\Users\\TIMBUC~1\\AppData\\Local\\Temp\\pip-install-qwvadbd5\\pyyawt\\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\TIMBUC~1\AppData\Local\Temp\pip-record-iksuld9r\install-record.txt –single-version-externally-managed –compile” failed with error code 1 in C:\Users\TIMBUC~1\AppData\Local\Temp\pip-install-qwvadbd5\pyyawt\
Do you have any idea how I could fix this?
I didn’t try to compile PyYAWT myself but from the trace, I wouldn’t say it is an issue with the python path. In the documentation of the project, under ‘developmnt notes’, compiling under Windows seem to require to set some environment variables. Did you do it?
C:\Users\meet2>pip install –upgrade setuptools
[…]
Successfully installed setuptools-40.0.0
building ‘_mysql’ extension
error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: http://landinghub.visualstudio.com/visual-cpp-build-tools
You do not indicate if you use the proper command prompt to compile the extension. Updating setuptools alone does not suffice.
Hi Dimitri!
I have installed setuptools, but anyway I have 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
Error code 2 means file not found. Updating python’s setuptools does the python part to avoid the concurrent installation of several Visual Studio versions. However you must still install the Visual Studio 2017 C++ buid tools to get cl.exe.
Hi Dimitri!
I am getting the same error. I looked in the directory and the file “cl.exe” is there. I am not sure why it can’t execute it. Any thoughts?
As mentioned above, what do you get when executing cl.exe /?
I am calling it from visual studio x64 command line and getting the following output. I found “cl.exe”
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools>pip install pygraphviz
Collecting pygraphviz
Using cached https://files.pythonhosted.org/packages/7e/b1/d6d849ddaf6f11036f9980d433f383d4c13d1ebcfc3cd09bc845bda7e433/pygraphviz-1.5.zip
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz … error
Complete output from command c:\users\kyle\appdata\local\programs\python\python37\python.exe -u -c “import setuptools, tokenize;__file__=’C:\\Users\\kyle\\AppData\\Local\\Temp\\pip-install-xmq_fo3d\\pygraphviz\\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\kyle\AppData\Local\Temp\pip-record-tuojb_ti\install-record.txt –single-version-externally-managed –compile:
running install
include_dirs=None
library_dirs=None
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\agraph.py -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\graphviz.py -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\release.py -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\version.py -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\__init__.py -> build\lib.win-amd64-3.7\pygraphviz
creating build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_attributes.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_attribute_defaults.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_clear.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_drawing.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_edge_attributes.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_graph.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_html.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_layout.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_node_attributes.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_readwrite.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_setup.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_string.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_subgraph.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_unicode.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\__init__.py -> build\lib.win-amd64-3.7\pygraphviz\tests
running egg_info
writing pygraphviz.egg-info\PKG-INFO
writing dependency_links to pygraphviz.egg-info\dependency_links.txt
writing top-level names to pygraphviz.egg-info\top_level.txt
reading manifest file ‘pygraphviz.egg-info\SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no files found matching ‘*.png’ under directory ‘doc’
warning: no files found matching ‘*.html’ under directory ‘doc’
warning: no files found matching ‘*.txt’ under directory ‘doc’
warning: no files found matching ‘*.css’ under directory ‘doc’
warning: no previously-included files matching ‘*~’ found anywhere in distribution
warning: no previously-included files matching ‘*.pyc’ found anywhere in distribution
warning: no previously-included files matching ‘.svn’ found anywhere in distribution
no previously-included directories found matching ‘doc\build’
writing manifest file ‘pygraphviz.egg-info\SOURCES.txt’
copying pygraphviz\graphviz.i -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\graphviz_wrap.c -> build\lib.win-amd64-3.7\pygraphviz
running build_ext
building ‘pygraphviz._graphviz’ extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\pygraphviz
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\kyle\appdata\local\programs\python\python37\include -Ic:\users\kyle\appdata\local\programs\python\python37\include “-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include” “-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt” “-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include” “-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt” /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-3.7\Release\pygraphviz/graphviz_wrap.obj
error: command ‘C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe’ failed: Invalid argument
Apparently the pygraphviz package calls cl.exe with one or more arguments which are not supported in this release.
SO it’s more a C++ issue than a Pythone one.
Did try try to run cl.exe /? to see which switches are supported.
Getting the same error for Python’s Falconn library -> https://ibb.co/vPP9z23
Please help!
And since you get a “Not Found” Error, you must check you have installed the C/C++ compiler component. Python build chain is fine.
Thank you, very helpful
Hi!
So: running from x64 native tools prompt, have ´[vcvarsall.bat] Environment initialized for: ‘x64’´,
setuptools is >40 (as can be seen from the log), but It stil asks me to install 14.0:
´´´
c:\Users\laurjo\Downloads>pip install line_profiler
Collecting line_profiler
Downloading https://files.pythonhosted.org/packages/14/fc/ecf4e238bb601ff829068e5a72cd1bd67b0ee0ae379db172eb6a0779c6b6/line_profiler-2.1.2.tar.gz (83kB)
100% |████████████████████████████████| 92kB 1.4MB/s
Requirement already satisfied: IPython>=0.13 in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from line_profiler) (6.1.0)
Requirement already satisfied: simplegeneric>0.8 in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (0.8.1)
Requirement already satisfied: pygments in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (2.2.0)
Requirement already satisfied: setuptools>=18.5 in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (40.6.2)
Requirement already satisfied: pickleshare in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (0.7.4)
Requirement already satisfied: prompt-toolkit=1.0.4 in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (1.0.14)
Requirement already satisfied: traitlets>=4.2 in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (4.3.2)
Requirement already satisfied: decorator in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (4.0.11)
Requirement already satisfied: colorama; sys_platform == “win32” in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (0.3.9)
Requirement already satisfied: jedi>=0.10 in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from IPython>=0.13->line_profiler) (0.10.2)
Requirement already satisfied: six>=1.9.0 in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from prompt-toolkit=1.0.4->IPython>=0.13->line_profiler) (1.11.0)
Requirement already satisfied: wcwidth in c:\users\laurjo\appdata\local\programs\python\python36\lib\site-packages (from prompt-toolkit=1.0.4->IPython>=0.13->line_profiler) (0.1.7)
Requirement already satisfied: ipython-genutils in c:\users\laurjo\appdata\local\programs\python\python36\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:\users\laurjo\appdata\local\programs\python\python36\python.exe -u -c “import setuptools, tokenize;__file__=’C:\\Users\\laurjo\\AppData\\Local\\Temp\\pip-install-w5oj5_fi\\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\laurjo\AppData\Local\Temp\pip-record-u66cscjg\install-record.txt –single-version-externally-managed –compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
copying line_profiler.py -> build\lib.win-amd64-3.6
copying kernprof.py -> build\lib.win-amd64-3.6
copying line_profiler_py35.py -> build\lib.win-amd64-3.6
running build_ext
skipping ‘_line_profiler.c’ Cython extension (up-to-date)
building ‘_line_profiler’ extension
error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: https://visualstudio.microsoft.com/downloads/
—————————————-
Command “c:\users\laurjo\appdata\local\programs\python\python36\python.exe -u -c “import setuptools, tokenize;__file__=’C:\\Users\\laurjo\\AppData\\Local\\Temp\\pip-install-w5oj5_fi\\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\laurjo\AppData\Local\Temp\pip-record-u66cscjg\install-record.txt –single-version-externally-managed –compile” failed with error code 1 in C:\Users\laurjo\AppData\Local\Temp\pip-install-w5oj5_fi\line-profiler\
´´´
So, any idea what else may I be missing?
From your message, the python part is fine. That’s the C++ complier which is not fine.
I would check that the C++ compiler is indeed accessible from a vcvarsall.bat prompt, and then that it is the expected version.
I’m assuming you are reviewed the Visual studio options by launching the Visual Studio installer and checking the C/C++ option is installed. The “standard” workloads from Microsoft do not necessarily include it (e.g. ‘Web development’ may bring you C# but not C++).
error: command ‘C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe’ faile
d with exit status 2
You may want to look at the previous comment
Dear Dimitri
I am trying to install line-profiler , and ran into similar problems.
I tried everything you listed, for example:
1. installed build tools 2019 (I also checled everything optional but related to C++ in the installer )
2. update set up tools ( i have two setup tools now in my environment though: one is from conda default (40.6.3), one is from pip (41.0.1)
3. run pip install line_profiler under build tool naive x64 environment.
still no luck and get exit staus 2 message. I ran cl.exe in naive x64 command prompt and it seems the computer know where it is.
so whats wrong? any suggestions. it has been bothering me for a long time.
ERROR msg:
ERROR: Failed building wheel for line-profiler
Running setup.py clean for line-profiler
Failed to build line-profiler
Installing collected packages: line-profiler
Running setup.py install for line-profiler … error
ERROR: Complete output from command ‘c:\users\tangjny\software\anaconda3\python.exe’ -u -c ‘import setuptools, tokenize;__file__='”‘”‘C:\\Users\\TANGJNY\\AppData\\Local\\Temp\\pip-install-ekknrusv\\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\TANGJNY\AppData\Local\Temp\pip-record-immikzrd\install-record.txt’ –single-version-externally-managed –compile:
ERROR: 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
skipping ‘_line_profiler.c’ Cython extension (up-to-date)
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\2019\BuildTools\VC\Tools\MSVC\14.20.27508\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\tangjny\software\anaconda3\include -Ic:\users\tangjny\software\anaconda3\include “-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\ATLMFC\include” “-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\include” “-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt” “-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\ATLMFC\include” “-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\include” “-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.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:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7891): error C2039: ‘exc_value’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7892): error C2039: ‘exc_traceback’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7899): error C2039: ‘exc_type’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7900): error C2039: ‘exc_value’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7901): error C2039: ‘exc_traceback’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7902): error C2039: ‘exc_type’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7903): error C2039: ‘exc_value’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7904): error C2039: ‘exc_traceback’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7959): error C2039: ‘exc_type’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7960): error C2039: ‘exc_value’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7961): error C2039: ‘exc_traceback’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7962): error C2039: ‘exc_type’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7963): error C2039: ‘exc_value’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
_line_profiler.c(7964): error C2039: ‘exc_traceback’: is not a member of ‘_ts’
c:\users\tangjny\software\anaconda3\include\pystate.h(212): note: see declaration of ‘_ts’
error: command ‘C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.20.27508\\bin\\HostX86\\x64\\cl.exe’ failed with exit status 2
—————————————-
ERROR: Command “‘c:\users\tangjny\software\anaconda3\python.exe’ -u -c ‘import setuptools, tokenize;__file__='”‘”‘C:\\Users\\TANGJNY\\AppData\\Local\\Temp\\pip-install-ekknrusv\\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\TANGJNY\AppData\Local\Temp\pip-record-immikzrd\install-record.txt’ –single-version-externally-managed –compile” failed with error code 1 in C:\Users\TANGJNY\AppData\Local\Temp\pip-install-ekknrusv\line-profiler\
I managed to install with conda, which avoid C binaries….not a beautiful solution but works for now.
still curious my problem with pip install though.
WHat’s the output of
where /R C:\ cl.exe
? Do you have the same location as the one shown on the ERROR: line of your message?when i executed the command ‘pip install scrapy’ there was no error
but i try to install rasa nlu it gives me following error:
Building wheels for collected packages: httptools
Building wheel for httptools (setup.py) … error
ERROR: Command errored out with exit status 1:
command: ‘e:\anaconda\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘”‘”‘C:\\Users\\sajjan\\AppData\\Local\\Temp\\pip-install-8jpt9ue2\\httptools\\setup.py'”‘”‘; __file__='”‘”‘C:\\Users\\sajjan\\AppData\\Local\\Temp\\pip-install-8jpt9ue2\\httptools\\setup.py'”‘”‘;f=getattr(tokenize, ‘”‘”‘open'”‘”‘, open)(__file__);code=f.read().replace(‘”‘”‘\r\n'”‘”‘, ‘”‘”‘\n'”‘”‘);f.close();exec(compile(code, __file__, ‘”‘”‘exec'”‘”‘))’ bdist_wheel -d ‘C:\Users\sajjan\AppData\Local\Temp\pip-wheel-wm3o5qcv’ –python-tag cp37
cwd: C:\Users\sajjan\AppData\Local\Temp\pip-install-8jpt9ue2\httptools\
Complete output (21 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\httptools
copying httptools\__init__.py -> build\lib.win-amd64-3.7\httptools
creating build\lib.win-amd64-3.7\httptools\parser
copying httptools\parser\errors.py -> build\lib.win-amd64-3.7\httptools\parser
copying httptools\parser\__init__.py -> build\lib.win-amd64-3.7\httptools\parser
running egg_info
writing httptools.egg-info\PKG-INFO
writing dependency_links to httptools.egg-info\dependency_links.txt
writing top-level names to httptools.egg-info\top_level.txt
reading manifest file ‘httptools.egg-info\SOURCES.txt’
reading manifest template ‘MANIFEST.in’
writing manifest file ‘httptools.egg-info\SOURCES.txt’
copying httptools\parser\parser.c -> build\lib.win-amd64-3.7\httptools\parser
running build_ext
building ‘httptools.parser.parser’ extension
error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: https://visualstudio.microsoft.com/downloads/
—————————————-
ERROR: Failed building wheel for httptools
From your trace, it is unclear if you’re using the Visual Studio command prompt or the Anaconda prompt. Could you check?