Unable to build talib 64 bit - python

I am trying to build talib for 64 bit Python. I have a 64 bit Python installation (Using Anaconda 64 bit distribution). I installed Microsoft SDK and set the environment to x64 using the following command
"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
but still no success. I have been struggling with this for past 2 days. Please help.
Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.1
\.
Targeting Windows 7 x64 Debug
C:\ABC\Python\pkgs\ta-lib\ta-lib-TA_Lib-0.4.7\ta-lib-TA_Lib-0.4.7>C:\Anaconda64\
python.exe setup.py build --compiler msvc
running build
running build_py
running build_ext
skipping 'talib\common.c' Cython extension (up-to-date)
building 'talib.common' extension
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64\cl.exe /c /nolo
go /Ox /MD /W3 /GS- /DNDEBUG -IC:\Anaconda64\lib\site-packages\numpy\core\includ
e -Ic:\ta-lib\c\include -IC:\Anaconda64\include -IC:\Anaconda64\PC /Tctalib\comm
on.c /Fobuild\temp.win-amd64-2.7\Release\talib\common.obj
common.c
C:\Anaconda64\include\pyconfig.h(68) : fatal error C1083: Cannot open include fi
le: 'io.h': No such file or directory
error: command 'cl.exe' failed with exit status 2
C:\ABC\Python\pkgs\ta-lib\ta-lib-TA_Lib-0.4.7\ta-lib-TA_Lib-0.4.7>

Download TA_Lib-0.4.10-cp27-cp27m-win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib.
And use command
pip install TA_Lib-0.4.10-cp27-cp27m-win_amd64.whl

Related

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.

Fail downloading cx_Freeze

I am getting this error trying to download cx_Freeze.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\BregmanM\Downloads\cx_Freeze-5.0.2>python setup.py install
running install
running bdist_egg
running egg_info
writing cx_Freeze.egg-info\PKG-INFO
writing dependency_links to cx_Freeze.egg-info\dependency_links.txt
writing top-level names to cx_Freeze.egg-info\top_level.txt
reading manifest file 'cx_Freeze.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.txt'
writing manifest file 'cx_Freeze.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
running build_ext
building 'cx_Freeze.util' extension
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\BregmanM\AppData\Local\Pro
grams\Python\Python36-32\include -IC:\Users\BregmanM\AppData\Local\Programs\Pyth
on\Python36-32\include /Tcsource/util.c /Fobuild\temp.win32-3.6\Release\source/u
til.obj
error: command 'cl.exe' failed: No such file or directory
But the problem here is I tied to fix the PATH issue and that did not work for me (python pip on Windows - command 'cl.exe' failed). I also must note, that I cannot just download using pip install because I am on a work computer that blocks me from doing so. My only option is to download the whl or tar.gz file. How can I go about fixing this? I am running on Python 3.6 so using py2exe will not work.
When I tried adding to PATH this is what I get:
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\BregmanM\AppData\Local\Programs\Python\Python36-32\include -IC:\Users\BregmanM\AppData\Local\Programs\Python\Python36-32\include /Tcsource/util.c /Fobuild\temp.win32-3.6\Release\source/util.obj
error: command 'cl.exe' failed: No such file or directory
Here is what my directory looks like:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe
I also have another 6 folders than contain cl.exe, but I'm assuming they are different. I even tried adding those to PATH but I get more errors.

Build Python package with C bindings in Windows (VC90) causes LNK1181 fatal error

I'm trying to build a Python package (pyspotify) with bindings to a C library (libspotify).
I'm using Python 2.7.5 and have installed VS2008 Express for some required commandline tools.
When I call python setup.py build from the Command Prompt (with Admin rights) I get the following output:
running build
running build_py
running build_ext
building 'spotify._spotify' extension
And then ~18 of these, one for each .c file in the package:
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -Isrc -Ic:\Python\Python27\include -Ic:\Python\Python27\PC
/Tcsrc\module.c /Fobuild\temp.win32-2.7\Release\src\module.obj
module.c
And then the showstopper:
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo
/INCREMENTAL:NO /LIBPATH:c:\Python\Python27\libs /LIBPATH:c:\Python\Python27\PCb
uild spotify.lib /EXPORT:init_spotify build\temp.win32-2.7\Release\src\module.ob
j build\temp.win32-2.7\Release\src\session.obj build\temp.win32-2.7\Release\src\
link.obj build\temp.win32-2.7\Release\src\track.obj build\temp.win32-2.7\Release
\src\album.obj build\temp.win32-2.7\Release\src\albumbrowser.obj build\temp.win3
2-2.7\Release\src\artist.obj build\temp.win32-2.7\Release\src\artistbrowser.obj
build\temp.win32-2.7\Release\src\search.obj build\temp.win32-2.7\Release\src\pla
ylist.obj build\temp.win32-2.7\Release\src\playlistcontainer.obj build\temp.win3
2-2.7\Release\src\playlistfolder.obj build\temp.win32-2.7\Release\src\image.obj
build\temp.win32-2.7\Release\src\user.obj build\temp.win32-2.7\Release\src\pyspo
tify.obj build\temp.win32-2.7\Release\src\toplistbrowser.obj /OUT:build\lib.win3
2-2.7\spotify\_spotify.pyd /IMPLIB:build\temp.win32-2.7\Release\src\_spotify.lib
/MANIFESTFILE:build\temp.win32-2.7\Release\src\_spotify.pyd.manifest
LINK : fatal error LNK1181: cannot open input file 'spotify.lib'
error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.
exe"' failed with exit status 1181
And I have tried to search for this LNK1181 error, but all answers seems to be about remembering quotes around string, or some settings in VS which I in this case has no control over.
You need to download the appropriate version of libspotify from here unzip it and put it in the same directory that you are trying to build in, (easiest place), or tell VS where to find it.

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