Windows / PyPi / PyCharm linker errors when compiling some cython modules - python

currently, i am working with PyCharm on Windows, and i tried to install some packages via PyPi. For convinience, i used the integrated functionality of PyCharm, which does essentially the same as the shell easy_install.
However, when installing packages which have to be compiled with gcc, i get some errors. I already browsed a lot of questions here on stackoverflow because of the former errors, and managed to overcome some of the errors (using mingw64, removing the -mno-cygwin parameter from the setup scripts etc) but now i'm totally stuck on this one:
build\temp.win-amd64-2.7\Release\cpyamf\amf0.o:amf0.c:(.text+0xb912): undefined reference to `__imp_PyExc_ImportError'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/bin/ld.exe: build\temp.win-amd64-2.7\Release\cpyamf\amf0.o: bad reloc address 0x78 in section `.data'
collect2.exe: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
The error occurs on the installation of PyAMF and Twisted, which use cython for some parts. I couldn't find a solution for that one yet.
Thanks in advance.

I solved it with help from the folks at #python on freenode. Or better: found a workaround.
The problem was basically that i used 64 bit python on windows, which doesn't really work well with minGW64 and stuff.
I installed 32 bit Python, edited the distutils.cfg fixed the -mno-cygwin problem and it basically worked out of the box.
So if anyone else encounters this problem: Use 32 bit Python.

Related

pip installations failed: cl.exe failed with exit status 2

I know, there are many similar questions. I tried all solutions but non of them worked for me. I've been trying for hours and am now indescribably in a bad mood.
I want to install a few packages using pip (for example pip install mysql), but I always get (since 5 hours) this error:
_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
error: command 'C:\\Users\\myName\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
I do not understand whose idea it was to program such a stupid bug in Python, or that meaningless error. Sackoverflow is full of questions of this kind.
However, I installed Visual Studio 2015 and GCC (MinGW). Im using Python 2.7 which must be compatible to Visual C++ for Python 9.0. Nothing solved my problem. Downloading a precompiled file wouldn't solve the main issue. I'm hating python since ever but the last 5 hours put me on a new level of hating.
Now, a few hours later a found the solution. I don't know why, but you can't install mysql, mysql-python or mysqldb, because something is wrong with the package. (see "Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python) I don't understand, how someone can publish a broken installer but however they did.
The solution that worked for me is, using
pip install mysql-connector-python
instead. Thats it. It took me about 6 hours to find that out. More about that: https://dev.mysql.com/doc/connector-python/en/connector-python-installation-binary.html

Config variable 'Py_DEBUG' is unset

I tried installing matplotlib whl file in python 3.6 on windows but I all I got was this error:
C:\Python36\lib\site-packages\wheel\pep425tags.py:77: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect warn=(impl == 'cp')):
I tried debugging it but it seems to be a real issue here:
https://github.com/pypa/pip/issues/3383
Could someone please let me know how do I solve this error?
Any help would be appreciated.
Thanks.
Although this answer is irrelevant (and outdated) to the original question, people come here after Googling for this very error.
At the end of the day, it usually turn out to be some kind of package compilation error when using pip install . and build related installs. Most likely because the build config was made primarily for a unix OS and not windows. Who knows. So try to use a different compiler or make sure you have installed all the required compiler components. I.e. for Windows that is a >7 GB of Visual Studio C/C++ development/tools install. You may also try the 1 GB MinGW install.
However, the following official documentation clearly state the use for Py_DEBUG.
Compiling the interpreter with the Py_DEBUG macro defined produces what is generally meant by a debug build of Python. Py_DEBUG is enabled in the Unix build by adding --with-pydebug to the ./configure command. It is also implied by the presence of the not-Python-specific _DEBUG macro. When Py_DEBUG is enabled in the Unix build, compiler optimization is disabled.
Further info can be found here:
https://docs.python.org/3/using/configure.html#debug-build

Python on Windows - compiling

Like many before me I don´t succeed in installing a few Python packages (mysql, pycld2, etc.) on Windows. I have a Windows 8 machine, 64-bit, and Python 3.4. At first I got the well-known error "can´t find vcvarsall.bat - install VS C++ 10.0". This I tried to solve by installing MinGW and use that as compiler. This did not work. Then finally I found an installer for this VS C++ 10.0 here http://microsoft-visual-cpp-express.soft32.com/free-download/. This doesn´t work too good either. Now it seems to find the vcvarsall file but instead gives me a couple of new errors
nclude -IC:\Python34\include /Tc_mysql.c /Fobuild\temp.win32-3.4\Release\_mysql.
obj /Zl_mysql.c_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':
No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\cl.exe' failed with exit status 2
And:
pycldmodule.cc
bindings\pycldmodule.cc(16) : fatal error C1083: Cannot open include file: '
strings.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\cl.exe' failed with exit status 2
So now it doesn´t find strings.h and config-win.h and I´m too new to these sorts of problems to know what to look for. Anyone knows what I should do?
The thing is that I could just not use Windows and go over to Ubuntu as, for what I´ve understood, works painlessly with python. However, I have to use the win32com package which doesn´t exist on Ubuntu (have I understood that right?).
If I can´t solve these installing hassles on Windows, would a solution be to use a Windows virtual machine for the win32com part and do the rest on a host Ubuntu (or the other way around)? Would there be anyway to communicate between the two in that case? I.e. sending strings or arrays of data.
I have faced the exact same issues for Python 2.7 on 64 bit Windows trying to install pycld2.
Tried many methods like installing VS express 2008, MingW, etc and it just doesnt work.
What saved me is this link:
https://github.com/aboSamoor/polyglot/issues/11
The proposed solution is to download the binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and pip install .whl
The cpXX denotes the version of python. So in my case, I used cp27.
Hope it helps
I would recommend installing Ubuntu (as a Ubuntu user), you can dual-boot. However, that isn't an answer.
MySQLClient (the fork for Python3) is available a precompiled binary from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient
Try to find precompiled binaries for simplicity sake. As far as troubleshooting the install goes, I've tried the recommend VC Studio 9.0 on fresh installs and it cannot find stdint.h (which, like yours, suggests it's more than broken).
You could try http://www.activestate.com/activepython/downloads for Windows. I t includes compiled binaries, avoiding the need for a C complier.
I grew frustrated with trying to get python and other packages to compile/play nicely on Windows as well. Switching over to Ubuntu was a breath of fresh air, for sure.
The win32com package is made specifically for Windows hosts, so that could not longer be used, but there are other ways to achieve the same thing in Ubuntu.
Are you trying to target Windows specifically? What are you using win32com for?
Looks like you're missing MySQL dev package. Another StackOverflow question has the details. But if I were you, I'd go the route Alexander Huszagh recommended and get my precompiled binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient

Getting Cython to work in Windows 7 with Eclipse PyDev

I'm a newbie trying to learn Cython. My operating system is Windows 7 and I'm using Eclipse PyDev as my IDE for Python development.
I have tried to install and test Cython according to this guide:
Here is the content of my environment variable PATH:
C:\texlive\2012\bin\win32;C:\Users\jjepoh\Jonne's_Programs\CodeBlocks\MinGW\bin;C:\Users\jjepoh\Jonne's_Programs\SSH client;C:\Users\jjepoh\Jonne's_Programs\Python\Scripts;
MinGW is installed under Codeblocks:
I have installed Cython 0.20.1 using the Windows binaries from here:
I have Python 2.7.5 installed:
Here you can see Cython installed under Python:
My hello.pyx, test_cython.py and setup.py according to the guide:
It seems I can compile the c-file, but I am doing something wrong I think..here is the end result:
Do you guys have any idea, what am I missing here? Why can't I import the hello.pyx module?
Thank you for any assistance. Sorry for the large amount of pictures, I thought it would help to give as much details as possible. I will give more details when asked =)
I got it solved with the hints provided by user #IanH =)
Here are the links to the solution:
error: Unable to find vcvarsall.bat
Compiling with cython and mingw produces gcc: error: unrecognized command line option '-mno-cygwin'
Here you can see the result =)

py-bcrypt installing on win 7 64bit python

Trying to install py-bcrypt on win7. Python is 64bit. First error unable to find vcvarsall.bat. Googled a bit learned that i needed to install mingw. installed it now this
C:\tools\python_modules\py-bcrypt-0.2>python setup.py build -c mingw32
running build
running build_py
running build_ext
building 'bcrypt._bcrypt' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\Python27\include -Ic:\Python27\PC -c bcrypt/bcrypt_python.c -o b
d\temp.win-amd64-2.7\Release\bcrypt\bcrypt_python.o
bcrypt/bcrypt_python.c:29:26: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c:29:38: error: expected declaration specifiers or '...' before 'u_int16_t'
bcrypt/bcrypt_python.c:29:49: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c: In function 'bcrypt_encode_salt':
bcrypt/bcrypt_python.c:56:2: error: too many arguments to function 'encode_salt'
bcrypt/bcrypt_python.c:29:6: note: declared here
error: command 'gcc' failed with exit status 1
no idea what to do next. guess i'll just not use bcrypt and try something else. Any other suggestions?
There is a compiled version of py-bcrypt for windows. You can visit https://bitbucket.org/alexandrul/py-bcrypt/downloads to download the .exe file and install.
I've looked at the bcrypt source, and can't figure out why you're getting the error you are (don't have a Windows system at hand to test on right now). Though looking at the pybcrypt issue tracker it looks like it has other Windows compilation problems, so it's probably not just you. At a guess though, adding "--std=C99" to the gcc arguments via extra_compile_args might fix at least some of the errors.
Aside from that, there are a couple of alternatives -
Bcryptor is another C-extension bcrypt implementation which may compile for your system.
Passlib is a general password hashing library. While it relies on bcryptor/pybcrypt for bcrypt support, it has builtin support for a number of other password hashes that may work for you - such as SHA512-Crypt or PBKDF2-HMAC-SHA512
Cryptacular is another general password hashing library. On Windows, it provides both BCrypt and PBKDF2-HMAC-SHA512 password hashes. (I'd link straight to those, but the documentation won't quite let me).
I stumbled upon this rather old thread while trying to get py-bcrypt installed (via pip) on Windows 7 using VS2012. Apparently, this still doesn't work (I also get the "missing vcvars.bat" error).
There is a dedicated Windows fork for py-bcrypt called py-bcrypt-w32, which I could install without any problems using
pip install py-bcrypt-w32
I had the same issue and I fixed it by applying the patch found at this link:
http://code.google.com/p/py-bcrypt/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&groupby=&sort=&id=1
py-bcrypt_11.patch
Had to apply it manually.
From that thread, the source of the problem is
According to http://groups.google.com/group/mpir-devel/msg/2c2d4cc7ec12adbb (flags defined under the various windows OS'es ,cygwins,mingw's and other's) its better to use _WIN32 instead of _MSC_VER, Together with the change from bzero to memset this compiles both under MSVC and MingW32.
Hope that helps!
supposing you are using mingw64, you should change _MSC_VER in _WIN32 on ifdefs into bcrypt.c, bcrypt_python.c and pybc_blf.h
I had this same problem with python 3.4.1, and none of the previous answers worked. I eventually got the Visual Studio 2010 64-bit compiler working, and hence both cryptacular and py-bcrypt installed with easy_install. See my detailed answer here: https://stackoverflow.com/a/27033824/3800244
It's 2016 and I have faced same issue. Download the wheel directly from https://bitbucket.org/alexandrul/py-bcrypt/downloads and then run following
pip install <whl-file>

Categories

Resources