Python TA-Lib install problems - python

Frustratingly having a lot of difficult installing the TA-Lib package in python.
https://pypi.python.org/pypi/TA-Lib
I have read through all the forum posts I can find on this but no such luck for my particular problem..
Windows 10
Python 3.5.2
Anaconda 4.2.0
Cython 0.24.1
Microsoft Visual Studio 14.0
I have downloaded and extracted  ta-lib-0.4.0-msvc.zip to C:/TA-Lib
(common problems seem to be people not installing the underlying TA-Lib file http://www.ta-lib.org/hdr_dw.html)
If someone could help me solve this I would be very appreciative!
Using 'pip install ta-lib' I get the following:
C:\Users\Matt>pip install ta-lib
Collecting ta-lib
Using cached TA-Lib-0.4.10.tar.gz
Building wheels for collected packages: ta-lib
Running setup.py bdist_wheel for ta-lib ... error
Complete output from command c:\users\matt\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Matt\\AppData\\Local\\Temp\\pip-build-vv02ktg_\\ta-lib\\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\Matt\AppData\Local\Temp\tmpqstzmsgspip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\talib
copying talib\deprecated.py -> build\lib.win-amd64-3.5\talib
copying talib\test_abstract.py -> build\lib.win-amd64-3.5\talib
copying talib\test_data.py -> build\lib.win-amd64-3.5\talib
copying talib\test_func.py -> build\lib.win-amd64-3.5\talib
copying talib\test_stream.py -> build\lib.win-amd64-3.5\talib
copying talib\__init__.py -> build\lib.win-amd64-3.5\talib
running build_ext
skipping 'talib\common.c' Cython extension (up-to-date)
building 'talib.common' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\talib
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\matt\anaconda3\lib\site-packages\numpy\core\include -Ic:\ta-lib\c\include -Ic:\users\matt\anaconda3\include -Ic:\users\matt\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tctalib\common.c /Fobuild\temp.win-amd64-3.5\Release\talib\common.obj
common.c
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\ta-lib\c\lib /LIBPATH:c:\users\matt\anaconda3\libs /LIBPATH:c:\users\matt\anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" ta_libc_cdr.lib /EXPORT:PyInit_common build\temp.win-amd64-3.5\Release\talib\common.obj /OUT:build\lib.win-amd64-3.5\talib\common.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.lib
common.obj : warning LNK4197: export 'PyInit_common' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.lib and object build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.exp
common.obj : error LNK2001: unresolved external symbol TA_SetUnstablePeriod
common.obj : error LNK2001: unresolved external symbol TA_Shutdown
common.obj : error LNK2001: unresolved external symbol TA_Initialize
common.obj : error LNK2001: unresolved external symbol TA_GetUnstablePeriod
common.obj : error LNK2001: unresolved external symbol TA_GetVersionString
build\lib.win-amd64-3.5\talib\common.cp35-win_amd64.pyd : fatal error LNK1120: 5 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120
----------------------------------------
Failed building wheel for ta-lib
Running setup.py clean for ta-lib
Failed to build ta-lib
Installing collected packages: ta-lib
Running setup.py install for ta-lib ... error
Complete output from command c:\users\matt\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Matt\\AppData\\Local\\Temp\\pip-build-vv02ktg_\\ta-lib\\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\Matt\AppData\Local\Temp\pip-qxmjmn5m-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\talib
copying talib\deprecated.py -> build\lib.win-amd64-3.5\talib
copying talib\test_abstract.py -> build\lib.win-amd64-3.5\talib
copying talib\test_data.py -> build\lib.win-amd64-3.5\talib
copying talib\test_func.py -> build\lib.win-amd64-3.5\talib
copying talib\test_stream.py -> build\lib.win-amd64-3.5\talib
copying talib\__init__.py -> build\lib.win-amd64-3.5\talib
running build_ext
skipping 'talib\common.c' Cython extension (up-to-date)
building 'talib.common' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\talib
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\matt\anaconda3\lib\site-packages\numpy\core\include -Ic:\ta-lib\c\include -Ic:\users\matt\anaconda3\include -Ic:\users\matt\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tctalib\common.c /Fobuild\temp.win-amd64-3.5\Release\talib\common.obj
common.c
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\ta-lib\c\lib /LIBPATH:c:\users\matt\anaconda3\libs /LIBPATH:c:\users\matt\anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" ta_libc_cdr.lib /EXPORT:PyInit_common build\temp.win-amd64-3.5\Release\talib\common.obj /OUT:build\lib.win-amd64-3.5\talib\common.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.lib
common.obj : warning LNK4197: export 'PyInit_common' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.lib and object build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.exp
common.obj : error LNK2001: unresolved external symbol TA_SetUnstablePeriod
common.obj : error LNK2001: unresolved external symbol TA_Shutdown
common.obj : error LNK2001: unresolved external symbol TA_Initialize
common.obj : error LNK2001: unresolved external symbol TA_GetUnstablePeriod
common.obj : error LNK2001: unresolved external symbol TA_GetVersionString
build\lib.win-amd64-3.5\talib\common.cp35-win_amd64.pyd : fatal error LNK1120: 5 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120
----------------------------------------
Command "c:\users\matt\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Matt\\AppData\\Local\\Temp\\pip-build-vv02ktg_\\ta-lib\\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\Matt\AppData\Local\Temp\pip-qxmjmn5m-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Matt\AppData\Local\Temp\pip-build-vv02ktg_\ta-lib\

You could try the "Unofficial Windows Binaries for Python Extension Packages
by Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine."
http://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
He has different versions compiled depending on OS and Python versions. You probably need TA_Lib‑0.4.10‑cp35‑cp35m‑win_amd64.whl
Good luck.

Download ta-lib-0.4.0-msvc.zip from http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib
This is a 32-bit release. If you want to use 64-bit Python, you will need to build a 64-bit version of the library.
Some unofficial (and unsupported) instructions for building on 64-bit Windows 10, here for reference:
Download and Unzip ta-lib-0.4.0-msvc.zip
Move the Unzipped Folder ta-lib to C:\
Download and Install Visual Studio Community 2015 or 2017 - have to do the big install i'm afraid - no other way
Remember to Select [Visual C++] Feature
Build TA-Lib Library - From Windows Start Menu, Start [VS2015 x64 Native Tools Command Prompt]
cd to C:\ta-lib\c\make\cdr\win32\msvc
Build the Library by typing nmake
Try installing ta-lib again from pip or pycharm etc...

you can proceed as follows:
Go to the following page: https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
Choose your version of python: cp35 means Python 3.5 (64 bit for example)
Download the package and unzip in ...\Python\Python35\Scripts
Go on cmd and in the same directory (...\Python\Python35\Scripts) execute the following command:
pip3 install TA_Lib-0.4.17-cp35-cp35m-win_amd64.whl
installed!

In order to use the python package you need the dependencies first. For mac you can just use brew install ta-lib and then pip install TA-Lib will work just fine.

While there are similar answers but I thought I would take a crack at it.
Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib and download the relevant .whl file.
From the info given, I would suggest the file name, TA_Lib‑0.4.17‑cp35‑cp35m‑win_amd64.whl
I find Anaconda environment good for python, so I would suggest installing Anaconda and placing the file in the same folder location which is shown on the Anaconda prompt.
screenshot of Anaconda installer
In the Anaconda prompt, use the pip install command with the file name of the downloaded file.
Since we have downloaded the file, TA_Lib‑0.4.17‑cp37‑cp37m‑win_amd64.whl, the command would be:
pip install TA_Lib‑0.4.17‑cp35‑cp35m‑win_amd64.whl`
If there is no error, then it implies that we have successfully installed Ta-Lib.
You should get something like this: install Ta-lib
Source: https://blog.quantinsti.com/install-ta-lib-python/

From https://github.com/mrjbq7/ta-lib:
'This typically means that it can't find the underlying TA-Lib library, a dependency which needs to be installed.'
Install the underlying TA-Lib library first from here:
https://www.ta-lib.org/hdr_dw.html
I used the 'ta-lib-0.4.0-msvc.zip' one.
Then download a whl file from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
I used the 'TA_Lib‑0.4.16‑cp35‑cp35m‑win_amd64.whl' one.
I can not definitely remember but I think I lastly ran pip install TA-Lib as well

I faced the same problems trying with Anaconda 5.1.0 and Python 3.6 via Visual Studio.
The solution was to get a wheel from https://www.lfd.uci.edu/~gohlke/pythonlibs, then install it via pip. You need to make sure the wheel matches your python version (in my case, 3.6).
In Anaconda, I just opened a prompt, navigated to where the wheel was, and ran the following:
python -m pip install TA_Lib-0.4.17-cp36-cp36m-win_amd64.whl
For Visual Studio, it was more obtuse. Go to the Python Environments tab, choose 'Overview' in the dropdown, then `Open in PowerShell'. At that point, run the same command as for ANaconda above.

Download related package from
https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
TA_Lib‑0.4.17‑cp36‑cp36m‑win_amd64.whl (Since I have python 3.6, cp36)
and use
pip install TA_Lib‑0.4.17‑cp36‑cp36m‑win_amd64.whl

The following solved the issue I had installing ta-lib for Python:
OS: Windows 10
Python: 2.7, embedded in miniconda.
Miniconda: 64 bits.
PyCharm 2018.1.4 Community Edition.
You need to convert ta-lib to 64 bits. You can find it already converted in here.
The site also tells you what to do, however there are several steps not included or confusing there that I am explaining here.
It is important that you do not just unzip the file 'ta-lib x64.zip' at 'C:'. Inside the zip file, there is a 'ta-lib' folder. This folder is the one that has to be in 'C:'
From the same github account, download and execute C++ Build Tools en_visual_cpp_build_tools_2015_update_3_x86_x64_8923157.exe.
Microsoft Visual C++ 9.0 is required. Get it from here.
You must download and install it, in case you don't already have it.
Inside your python environment, run pip install ta-lib
This worked for me, I hope this info is useful for you.
Note: At the time, there is no TA-lib developed for Python 3.x, that is why I used Python 2.7

Install an updated Microsoft visual c++ Redistributable for Visual Studio 2015, 2017 and 2019:
https://support.microsoft.com/he-il/help/2977003/the-latest-supported-visual-c-downloads
worked for me..

Had to spend good amount of time even with so many people facing the same issue. Long story short WINDOWS ***T. I am on Windows 10 running python3.7
Enough of ranting here are the steps that worked for me
Install Visual C++ Build tools (https://www.youtube.com/watch?v=P4_R34Lb-PE)
https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
While installing Build tools make sure you have selected Windows10 SDK that resolved some io.h file not found error. I had to modify the installation multiple times by adding Visual C++ components.
After this pip3 install ta-lib or python3 -m pip install ta-lib didn't work. What worked was downloading those .whl files as mentioned above [https://www.lfd.uci.edu/~gohlke/pythonlibs] and since I have python3.7 I had to select the one with cp37 (TA_Lib-0.4.18-cp37-cp37m-win_amd64.whl) in it.
I hope I am not missing any step but by the time I figured above steps I was 4 hours older.

From everything that I have tried, the simplest way to solve this was more obvious than it looked based on previous answers. Run the following command on your conda terminal:
conda install -c conda-forge ta-lib
Make sure you are running this command on the desired environment.

Related

Python package(s) install failure on packages that requires C source compiling (Visual Studio 2017)

In Visual Studio's Python, i can install packages, which as far as i know doesn't require C source compiling. When it comes to packages that requires compiling, it's always fail. My installation attempts are always done via pip install package-name inside the Visual Studio. This is what i have tried :
Installing Visual Studio 2015 (VS 14.0) C/C++ Standalone compiler
Try to re-install the package after compiler installation, still fail
Restarting the machine, then try to re-install the package, still fail
Specifically, i have tried to install RPIO and RPi.GPIO, more or less it give similar error message :
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
Here is the full log from the RPIO installation attempt :
----- Installing 'RPIO==0.10.0' -----
Collecting RPIO==0.10.0
Using cached RPIO-0.10.0.tar.gz
Installing collected packages: RPIO
Running setup.py install for RPIO: started
Running setup.py install for RPIO: finished with status 'error'
Complete output from command "C:\Program Files\Python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\ELEMEN~1\\AppData\\Local\\Temp\\pip-build-4lvb_8wu\\RPIO\\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\ELEMEN~1\AppData\Local\Temp\pip-oqz8bi8d-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\RPIO
copying source\RPIO\Exceptions.py -build\lib.win-amd64-3.6\RPIO
copying source\RPIO\_RPIO.py -build\lib.win-amd64-3.6\RPIO
copying source\RPIO\__init__.py -build\lib.win-amd64-3.6\RPIO
creating build\lib.win-amd64-3.6\RPIO\PWM
copying source\RPIO\PWM\__init__.py -build\lib.win-amd64-3.6\RPIO\PWM
running build_ext
building 'RPIO._GPIO' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\source
creating build\temp.win-amd64-3.6\Release\source\c_gpio
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files\Python36\include" "-IC:\Program Files\Python36\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt" /Tcsource/c_gpio/py_gpio.c /Fobuild\temp.win-amd64-3.6\Release\source/c_gpio/py_gpio.obj
py_gpio.c
source/c_gpio/py_gpio.c(361): error C2373: 'setmode': redefinition; different type modifiers
C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt\corecrt_io.h(528): note: see declaration of 'setmode'
source/c_gpio/py_gpio.c(431): warning C4028: formal parameter 1 different from declaration
source/c_gpio/py_gpio.c(431): warning C4028: formal parameter 2 different from declaration
source/c_gpio/py_gpio.c(431): warning C4047: 'initializing': 'PyCFunction' differs in levels of indirection from 'int (__cdecl *)(int,int)'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
Command ""C:\Program Files\Python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\ELEMEN~1\\AppData\\Local\\Temp\\pip-build-4lvb_8wu\\RPIO\\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\ELEMEN~1\AppData\Local\Temp\pip-oqz8bi8d-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ELEMEN~1\AppData\Local\Temp\pip-build-4lvb_8wu\RPIO\
----- Failed to install 'RPIO==0.10.0' -----
So am i missing something ? Or is it the package's source that missing something ?
Thank you
It looks like py_gpio.c is redefining setmode (line 361, used at line 431). This is a bug in their code, so you should find the team who owns it and report it to them. Most likely they added it to support older versions of MSVC, and should not add it for the current version.
It also appears that the code is using a different definition than what the C runtime has, which could later cause problems if the variable types do not match. A full code review may be needed here.
In any case, this appears to be a problem with the RPi.GPIO package and not with your install or the tools you are using.
First, thank you #martineau for hinting the problems
This is not a whole solution, but rather some workaround.
1. Use Another IDE / Tool
While the library still not compatible with the Windows toolchain, you can try another tool or IDE that might do.
2. Another library
This is the workaround that i take. Basically, i need Python library for accessing RPi GPIO, the said RPi.GPIO and RPIO won't be installed on the Windows ver. of Python, so i move to another library called gpiozero. It is compatible with the Windows Python (it's successfully pip-ed in VS) and so far provide functionalities that i need.

Unable to install mysqlclient Python package on Windows

I am trying to install the mysqlclient Python package (https://pypi.python.org/pypi/mysqlclient) into a virtual Python 2.7 environment on Windows 7 (on a local PC, and on the Appveyor CI) and cannot get it done.
I am describing the issues for the local PC with Win 7, but it happens basically the same way on Appveyor.
Packages in my virtualenv when I start:
pip (9.0.1)
setuptools (36.6.0)
wheel (0.30.0)
pip install mysqlclient initially says:
. . .
running build_ext
building '_mysql' extension
error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
Apparently, Python 2.7 requires VC9. After installing it, pip install mysqlclient gets a little further, but misses include files:
. . .
building '_mysql' extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -IC:\Python27\include -IC:\Users\Andi\virtualenvs\mysqlclient\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(29) : fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Common Files\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2
In order to get the header files, I installed the "MySQL Connector/C 6.1.10" from https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.10-winx64.msi. This is admittedly only the second latest version, but I need to install it on Appveyor from the command line, and did not find out how to download the latest version in an unattended manner.
Also, using the MSI installer installs the package in C:\Program Files\MySQL\MySQL Connector C 6.1 but the build step in pip install expects it in C:\Program Files (x86)\MySQL\MySQL Connector C 6.1, so I softlinked it:
mklink /D "C:\Program Files (x86)\MySQL\MySQL Connector C 6.1" "C:\Program Files\MySQL\MySQL Connector C 6.1"
When looking at the files in that version of the MySQL Connector/C, it has only lib/vs12 and lib/vs14 directories:
lib/vs12/mysqlclient.lib
lib/vs14/mysqlclient.lib
As expected, pip install mysqlclient now gets beyond the compiles, but fails when linking:
. . .
running build_ext
building '_mysql' extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -IC:\Python27\include -IC:\Users\Andi\virtualenvs\mysqlclient\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(242) : .... several warnings ...
C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO "/LIBPATH:C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib\vs9" /LIBPATH:C:\Python27\Libs /LIBPATH:C:\Users\Andi\virtualenvs\mysqlclient\libs /LIBPATH:C:\Users\Andi\virtualenvs\mysqlclient\PCbuild\amd64 /LIBPATH:C:\Users\Andi\virtualenvs\mysqlclient\PC\VS9.0\amd64 kernel32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:init_mysql build\temp.win-amd64-2.7\Release\_mysql.obj /OUT:build\lib.win-amd64-2.7\_mysql.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\_mysql.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\_mysql.pyd.manifest /MANIFEST
LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'
error: command 'C:\\Program Files (x86)\\Common Files\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1181
I did not find a version of the "MySQL Connector/C" package that can still be downloaded and that works with VC9. Using the mysqlclient.lib files in the vs12 or vs14 directories in this vc9 build results in unresolved symbols.
My questions are:
What package(s) do I need to use in order to get the right header files (e.g. mysql.h) and libraries (e.g. mysqlclient.lib) for a successful pip install mysqlclient on Windows 7?
More generally, what are the prerequisites for a successful pip install mysqlclient on Windows 7?
download mysqlclient from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
choose the version matching your python version, example mysqlclient‑1.4.2‑cp37‑cp37m‑win_amd64.whl, and then:
pip install wheel
pip install mysqlclient‑1.4.2‑cp37‑cp37m‑win_amd64.whl
Incidentally I ran into the same issue in July last year and only now finished an entry on my blog about it.
Basically, you're not going to like it, but you need to re-compile mysqlclient from scratch, because -- as you pointed out -- it's not available for Visual Studio 9 since a long time.
However, doing it right is somewhat tricky, because you need to fix some compilation issues that apparently aren't documented anywhere in Oracle's official documentation. There are also issues with the Python setup.py file, as it doesn't care about the platform architecture and always looks in the x86 directory. That's why you soft-linked the directory. There is an open issue on Github mentioning this.
So basically, using the VC++ for Python 2.7 you already installed:
Download the Oracle MySQL C Connector source code.
Download and install Microsoft Visual C++ Compiler for Python 2.7.
Use CMake to generate NMake Makefiles for the MySQL C Connector source code. Pay attention to environment variables, see this Github issue comment.
Compile the MySQL C Connector mysqlclient library using nmake mysqlclient.
Install the MySQL C Connector binary and add the compiled mysqlclient.
Run pip install mysqlclient again.
Step 4 is tricky, because Microsoft don't supply C99 stdint.h, inttypes.h and stdlib.h is missing lldiv_t. You can use this StackOverflow post to get stdint.h and inttypes.h and then manually define lldiv_t in decimal.h as:
typedef struct {
long long quot;
long long rem;
} lldiv_t;
You can also copy these headers from a newer Visual Studio, like 2013 and 2015. After that, as you had already figured out, you need to put the compiled mysqlclient.lib into C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib\vs9.
Then issue another pip install mysqlclient and you're all done.

GMPY2 Not installing, mpir.h not found

I am trying to install gmpy2 on my Anaconda Python 3.5 distribution using pip. I was able to install other modules such as primefac perfectly. When I try to install gmpy2 this is what I get:
(C:\Program Files\Anaconda3) C:\WINDOWS\system32>pip install gmpy2
Collecting gmpy2
Using cached gmpy2-2.0.8.zip
Building wheels for collected packages: gmpy2
Running setup.py bdist_wheel for gmpy2 ... error
Complete output from command "C:\Program Files\Anaconda3\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\HADIKH~1\\AppData\\Local\\Temp\\pip-build-hd7b270n\\gmpy2\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d C:\Users\HADIKH~1\AppData\Local\Temp\tmplefsjn80pip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_ext
building 'gmpy2' extension
creating build
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\src
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMPIR -DWITHMPFR -DWITHMPC "-IC:\Program Files\Anaconda3\include" "-IC:\Program Files\Anaconda3\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /Tcsrc\gmpy2.c /Fobuild\temp.win-amd64-3.5\Release\src\gmpy2.obj
gmpy2.c
c:\users\hadi khan\appdata\local\temp\pip-build-hd7b270n\gmpy2\src\gmpy.h(104): fatal error C1083: Cannot open include file: 'mpir.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
Failed building wheel for gmpy2
I have noticed that whenever I try installing gmpy2 on a computer I always get some sort of error and it is a different one every time. Can someone please tell me how to fix this.
Thanks.
The reason is some required packages (especially below packages) aren't installed.
GMP: GNU Multiple Precision Arithmetic Library
MPFR: GNU Multiple-precision floating-point rounding library
MPC: GNU Multiple-precision C library
you could install those packages by below commands:
apt-get install libgmp-dev
apt-get install libmpfr-dev
apt-get install libmpc-dev
I could install gmpy2 by installing those libraries.
the key point is remembering below hint when you got an error like above.
# include "***.h": ==> No such file or directory
apt-get install lib"***"-dev
I maintain gmpy2 and unfortunately I have not been able to build Windows binaries for Python 3.5 and later. gmpy2 relies on either the MPIR or GMP libraries, and the MPFR and MPC libraries. There are detailed instructions included in the source distribution but they are not trivial to build on Windows. It is probably impossible(*) to build MPIR, MPFR, and MPC via pip. I would use the pre-compiled binaries available from http://www.lfd.uci.edu/~gohlke/pythonlibs/
(*) I'm sure it is possible with enough effort but I haven't done it.
The answer above works as noted, but i had to also find out how to install a wheel, which is answered here How do I install a Python package with a .whl file?
specifically, by copying the wheel file and executing (in my case), using pip 9
pip install C:\Python35\gmpy2-2.0.8-cp35-cp35m-win32.whl
Use conda to install instead of pip. conda will take care of installing the necessary dependencies. The command is: conda install gmpy2

Exception while installing packages in Python

I am Getting this Exception while installing packages in Python.
uninstalled python and installed it again but there is no
C:\Users\ramasastri.g\Desktop\pycrypto-2.6>python setup.py install
running install
running build
running build_py
running build_ext
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Random.OSRNG.winrandom' extension
C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc/ -Isrc/inc-msvc/ -IC:\Python27\include -IC:\Python27\PC /Tcsrc/winrand.c /Fobuild\temp.win32-2.7\Release\src/winrand.obj
winrand.c
c:\python27\include\pyconfig.h(68) : fatal error C1083: Cannot open include file: 'io.h': No such file or directory
error: command '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe"' failed with exit status 2
Probably you are missing the c++ compiler.
I installed it using a pre-packaged version from here
My problem was inside a virtualenv. I could not install some packages and got the same fatal error c1083. I was trying Visual Studio and PTVS. Just installing Microsoft Visual C++ Compiler for Python 2.7 https://www.microsoft.com/en-us/download/details.aspx?id=44266 was not enough to fix the error, despite it is needed.
I have found the solution here http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/
The setuptools installed by virtualenv is too old (3.6). You need to remove it and reinstalling but, in the "Install python package" window in Visual Studio solution explorer, instead of using "setuptools" as the module name to install use "setuptools>=6.0".
Got the same error message and found the cause was that while I had set up the PATH variable correctly with the paths to Visual Studio and Python, I forgot to add the C:\Windows\System32 path.

Error in installing pymssql 1.0.2 on Windows 2003 x64

I am trying to install the latest version of pymssql (1.0.2) in my Windows 2003 x64.
However, I am constantly getting this error:
running install
running build
running build_py
running build_ext
building '_mssql' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG "-Ic:\Program Files\Microsoft SQL Server\80\Tool
s\DevTools\Include" -Ic:\mssql7\DevTools\Include -Id:\DEVEL\pymssql-DEVTOOLS\INCLUDE -Ic:\Python27\include -Ic:\Python27\PC /Tcmssqldbmodule.c /Fobuil
d\temp.win32-2.7\Release\mssqldbmodule.obj
mssqldbmodule.c
mssqldbmodule.c(50) : fatal error C1083: Cannot open include file: 'sqlfront.h': No such file or directory
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
Any ideas? Isn't sqlfront.h included in the installation of visual studio 2k8 (or any visual studios)
Thank you!
I had the same problem with Visual Studio 2008, Windows 7 64 and Python 2.7 (32 bits).
These were the steps I followed to solved it:
Install Visual Studio 2008 (32 bits).
Install Visual Studio 6.
Install Python 2.7 (32 bits)
Download pymssql (the same package you downloaded)
Try to compile the source code (the same you did when you got the error, you will get it again).
At the same directory where setup.py is, you should find a file named mssqldbmodule.c, open it.
Change the lines #include <sqlfront.h> and #include <sqldb.h> To #include "sqlfront.h" and #include "sqldb.h" So the compiler will look for sqlfront.h and sqldb.h files locally.
Copy the files sqlfront.h and sqldb.h from: C:\Program Files (x86)\Microsoft Visual Studio\VC98\Include (Visual Studio 6 installation) To you local directory (where setup.py is).
Copy the file NTWDBLIB.LIB from C:\Program Files (x86)\Microsoft Visual Studio\VC98\Lib
To your local directory.
Run again setup.py install
This way you will compile the library using the deprecated NTWDBLIB which is the one used by pymssql.
The directory <pymssql root>\freetds\vs2008_32\ (or <pymssql root>\freetds\vs2008_64\ if you use 64bits python) has not been set for header files and libs yet I think.
About freetds, please check the "Building FreeTDS" part of README_building_and_developing.rst.

Categories