Python on Windows - compiling - python

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

Related

Cannot open include file: 'SDL.h'

I'm desperate for any help that anyone can provide. I'm trying to install pygame 1.9.1 with 64 bit python 2.7 on a windows 64 bit machine. I have Visual Studio C++ Express 2008 and Visual Studio 2013, but the installation attempts to use the Express edition. This is the error message I keep getting: "fatal error C1083: Cannot open include file: 'SDL.h': No such file or directory."
I've downloaded the SDL library from libsdl.org
I've followed the tutorial from here: http://lazyfoo.net/SDL_tutorials/lesson01/windows/msvsnet0508e/index.php
(the program I wrote worked, but the pygame one still won't)
I've followed a video similar to the lazyfoo tutorial that told me to add additional libraries.
I tried to follow this response: Pygame cannot find include file "sdl.h"
(my setup.py doesn't have that line)
I've looked up the error message on microsoft's website, and I can't figure out how to fix it. I can't even find where the include statement is within the pygame files. Can anyone help?
Try PyGame binary from Unofficial Windows Binaries for Python Extension Packages - and you will have no need to compile it on your own.

trouble installing pcapy on windows 7 - cannot open include file: 'pcap.h'

I am trying to install pcapy on a Windows machine. I have already installed WinPcap 4.1.3
I downloaded pcapy 0.10.8 into C:\pcapy-0.10.8
When I try to do the install, the following happens:
C:\pcapy-0.10.8>c:\Python27\python.exe setup.py install
running install
running build
running build_ext
building 'pcapy' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\cl.exe /c /nolog o /Ox /MD /W3 /GS- /DNDEBUG -DWIN32=1 -Ic:\devel\oss\wpdpack\Include -Ic:\Python27\include -Ic:\Python27\PC /Tppcapdumper.cc /Fobuild\temp.win-amd64-2.7\Release \pcapdumper.obj
pcapdumper.cc
pcapdumper.cc(12) : fatal error C1083: Cannot open include file: 'pcap.h': No such file or directory
error: command 'cl.exe' failed with exit status 2
I don't know where it's looking for pcap.h. I can confirm that there is no file by that name in the pcapy-0.10.8 directory.
What am I missing? I just now installed WinPcap -- do I need a reboot or something? Thanks!
Edited to add... here is the output from my WinPcap install log:
WinPcap 4.1.0.2980 Installation LOG
-----------------------------------------------------
Debug Information
Operating system detected on registry: 7 - AMD64
True operating system (kernel.dll): 7 - AMD64
npptools.dll present on the system: false
netnm.inf present on the system: false
nmnt.sys present on the system: false
End of log
-----------------------------------------------------
Do the falses there mean that WinPcap did not get installed properly? I was hoping to find pcap.h under my WinPcap directory, but it's not there. I do see where I could add additional include file directories in the setup.py if needed, but I can't find pcap.h anywhere on my machine. Where am I supposed to be getting that from?
C:\pcapy-0.10.8>c:\Python27\python.exe setup.py install
From the text on the CoreLabs site for pcapy, that suggests that you downloaded the source rather than the Win32 binary. Unless you really need to build from source, you will probably find it a LOT easier to just install the binary.
Do the falses there mean that WinPcap did not get installed properly?
No.
I was hoping to find pcap.h
Then, IF you NEED to build from source, you need to install the WinPcap Developer's Pack. WinPcap is just the "run time", sufficient for programs such as Wireshark that have already been built, but not sufficient for software that uses WinPcap and that need to be compiled on your machine - and, apparently, whatever flavor of pcapy you downloaded needs to be built.
(This is similar to the way libpcap is packaged on many Linux distributions - the "libpcap" package just installs the run time, and you need to install a "libpcap-dev" package, or something such as that, to get the header files.)
But if the Windows binary works for you, don't bother with the WinPcap developer's pack.
Building on Josh P's answer (which I used to get most of the way there just now):
download the WinPcap Developer's pack
extract the zip file (e.g. c:\users\foo\Downloads\WpdPack_4_1_2)
build using the --global-option to pass in the header and linker locations
When specifying the library folder for the linker, on Windows 7, I needed to specify the x64 version of the lib, not the (default) x32 version of the lib:
pip install pcapy --global-option="build_ext"
--global-option="-Ic:\users\foo\Downloads\WpdPack_4_1_2\WpdPack\include"
--global-option="-Lc:\users\foo\Downloads\WpdPack_4_1_2\WpdPack\lib\x64"
I was getting the following link errors when using the ...\lib (x32) version of the file:
Creating library build\temp.win-amd64-2.7\Release\pcapy.lib and object build\temp.win-amd64-2.7\Release\pcapy.exp
pcapdumper.obj : error LNK2019: unresolved external symbol pcap_dump_close
referenced in function "void __cdecl pcap_dealloc(struct pcapdumper *)"
(?pcap_dealloc##YAXPEAUpcapdumper###Z)
As Guy Harris explained, it's generally easier to download install a binary. If you do build from source:
Download the WinPcap Developer's Pack.
Use pip's --global-option. setup.py is different, but I think pip is preferred over setup.py anyway.
Here's an example line (substitute in the correct paths for your system; I just referenced them right in the Downloads folder):
pip install ./pcapy-src-dir --global-option=build_ext --global-option="-LC:\path\to\WpdPack_4_1_2\WpdPack\Lib" --global-option="-IC:\path\to\WpdPack_4_1_2\WpdPack\Include
See also this answer.
In the pcapy-0.11.1 the setup.py is smarter, even smarter that what they described on their wiki page: https://github.com/CoreSecurity/pcapy/wiki/Compiling-Pcapy-on-Windows-Guide
The investigation demonstrated that's enough to set environment variable WPDPACK_BASE, so in Windows' case it may look like:
set WPDPACK_BASE=C:\Software\WpdPack
It's even able to detect if you need 32 or 64 bit version of these libraries.
Previous answers didn't help me solve the problem, but helped me digging. So they may be bit outdated.

pySide: ExtensionLoader_Pyside_QtGUI.py specified module could not be found

I'm using CXFreeze with PySide (QT). I get an error:
cx_Freeze: Python error in main script.
myscript.py line 33, in
File ExtensionLoader_Pyside_QtGUI.py, line 11, in
Import Error: DLL load failed: The specified module could not be found
When running a fresh install of Windows server 2008.
I'm running the frozen EXE package (with the folder). It seems to work on my own system and other systems. What might be the issue?
After reading, online, I tried to replace the Qt4Gui file, but this didn't solve the issue.
Python version is 2.7
Based on your Import Error: DLL load failed it is most likely an installation issue causing the missing DLL. To figure our exactly which DLL you are missing, use http://www.dependencywalker.com/ Run the .exe and open the .pyd file for File ExtensionLoader_Pyside_QtGUI.py and it will show you exactly which DLL's are missing and more importantly the locations where they should be. You can probably then track down the missing DLL online.
there are known issues with pyside 1.2.0 and cxFreeze. All should be fixed in development version (available on git repo). Please build the PySide from latest sources yourself or wait for PySide version 1.2.1. Build instructions are here [1].
[1] https://github.com/PySide/pyside-setup#building-pyside-on-a-windows-system
I used Py2exe instead of CXFreeze and it worked perfectly.
Also, apparently Python requires the MS Visual C++ Dependency Files:
http://www.microsoft.com/en-us/download/details.aspx?id=29
So any bundling needs that as well, if it's a fresh install. (Although I think they are now bundled with newer Windows versions.)
Other Notes:
In my experience, sometimes you should try CXFreeze, Py2EXE and PyInstaller quickly and see if one works best. As ideal as CXFreeze is re: cross platform, it just isn't going to happen perfectly.
Also, while I don't know if this was a factor, I set up a Windows 2000 Pro virtual machine and ran Py2exe on that. That was to ensure compatibility for all older Windows versions, and seemed to work well. (NOTE: Many things won't even run on Win2000 anymore so be careful that your other tools and libraries will run on it.)
Finally, be extra careful to match the bit level (32 vs 64) of all your libraries, and your Python install itself. If you have 32-bit python, ensure that your PySide, CXFreeze and any other libraries you use are 32-bit. (Or 64-bit if you're using 64-bit python.)

"Unable to find vcvarsall.bat" error on windows

6 hours ago i started searching for a solution to compile the c extentions for python 2.7 on windows 7.
I tried all possible solutions like taking an older MINGW version or trying it with the tdm-mingw version (4.4.) Also i tried to change the
"-Wall -mno-cygwin"
from the cygwinccompiler
and created the new file distutils.cfg with the new build
but i still get "at least" this error:
"error: command 'gcc' failed with exit status 1"
Is there anyone out there who can compile something like "pip install lxml" under windows?
If yes... please share your wisdom...;)
What kind of MINGW version are you running...what's your python version or how does your modified cygwinccompiler.py look like?
Have you tried Microsoft's Visual C++ Compiler?
If not, you may want to download "Microsoft Visual C++ Compiler for Python 2.7" here to see if you can avoid the "Unable to find vcvarsall.bat" error : https://www.microsoft.com/en-us/download/details.aspx?id=44266
That usually works for me on Windows with Python 2.7

Why do I get an error on the last line of installing Pylons 1.0 with easy_install and Python 2.7 in Windows Vista 64?

I tried to install Pylons 1.0 with Python 2.7 using the easy_install command in Windows Vista 64 but got the error:
raise ValueError(str(list(result.keys())))
ValueError: [u'path']
Here is the link to the whole installation process from command prompt
http://pastie.org/1190341
Why do I get this error?
How do I solve it?
Will Pylons work even though I got this error?
From the error:
File "C:\Python27\Lib\distutils\msvc9compiler.py", line 295, in q
uery_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: [u'path']
distutils looks for a file called vcvarsall.bat. It runs it and gets the include and lib directories that the batch file sets up. The batch file sets up the environment based on what platform you supply to it.
vcvarsall.bat should be in a directory like: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
Create following directories:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat
in vcvarsamd64.bat
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 /Release
All these above sets up windows tool chain to work with disutils. While you may have 64 bit python, most packages on pypi comes with 32 bit precompiled binaries. disutils needs to use your compiler tool chain for building 64 bit extensions. This is where all this come into picture.
Please look at :
http://blogs.msdn.com/b/vcblog/archive/2007/12/30/using-different-toolsets-for-vc-build.aspx
What vcvarsamd64.bat and other batchfile does is setup up paths for libs, tools etc which can be used by disutils.
[Edit: setenv.cmd not found in v6]
https://serverfault.com/questions/114998/vista-cmd-shell-thinks-its-windows-server-2008-debug
There's a workaround mentioned on pylons discuss list:
simplejson workaround for Pylons 0.9.7 on Windows, Python 2.6
It's a bit old (2008), but since your pasted output shows failure on compiling simplejson, it seems relevant. You might try following the suggestions there to see if it helps.
if you have installed x64 visual studio you can use the cmd tool in the visual studio tools in the start menu. It will set up the environment for you.
It looks like you couldn't build a C extension, something that is often difficult for Windows users. Try to find a Windows kit for Pylons. Or, look for help on installing MinGW so you can build the extensions.
I spent a huge amount of time trying to get the c++ compiler to work with 64 bit Python on 64 bit Windows. It turns out the answer was here.
http://msdn.microsoft.com/en-us/library/ms246588(v=vs.90).aspx
Run the VS 2008 Professional installer again and make sure make sure "X64 Compilers and Tools" is selected in the installer options.

Categories

Resources