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.
Related
I am trying to build the package, html5-parser for my Windows 10 python environment. I have read the instructions found here: https://html5-parser.readthedocs.io/en/latest/
but find them unclear.
The script that is used to run that package, while readily available from the Github repro doesn't work if run from the directory where it resides in that project. The reference above assumes the script will be run from a windows continuous integration server. Of course, my python development environment is not that.
I don't know how to proceed from here and I'm looking for some step by step instructions on how to build this package.
This is not final solution / answer, but I want to post some steps which can help to achieve final solution.
First, You need to install MSCV build tools, follow this tutorial and make sure You have all the packages.
Then clone html5-parse library:
https://github.com/kovidgoyal/html5-parser.git
Move win-ci.py from subfolder .github\workflows to the root folder of the repo (where setup.py is).
Edit win-ci.py and comment out lines:
#env = query_vcvarsall()
#os.environ.update(env)
From functions install_deps() and build().
Now open command line in the repo dictionary and run:
python win-ci.py install
This should install all dependencies.
After this, running python win-ci.py should execute build() function and finish installing of the library.
Unfortunately I had issues to make paths working properly.
After installing build tools I didn't have nmake.exe in path so I had to add it manually:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64
Then in build() step I've got stuck by missing sttdef.h.
I have library installed in C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt but still couldn't make it work.
TL;DR: how to use Cython as a distribution method instead of Py2exe, cx_freeze, pyinstaller, etc.
Following Making an executable in Cython, I'd like to see how it could be possible to distribute a Python program to any Windows user (who doesn't have Python already installed on his machine) by compiling it first with Cython --embed.
Let's use a test.py:
import json
print(json.dumps({'key': 'hello world'}))
and compile it:
cython test.py --embed
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
cl test.c /I C:\Python37\include /link C:\Python37\libs\python37.lib
It works and produces a 140KB test.exe executable.
Running test.exe on another machine doesn't work out-of-the-box, it requires:
python37.dll in the same folder
to install the usual vc_redist.x64.exe file
Even with this, it still does not work (screenshot below instead of copy/paste because I didn't manage the copy/paste in the VM - off topic here):
ModuleNotFoundError: No module named 'encodings'
Question: what is the minimal set of files required to distribute an --embed-Cython-compiled code and make it work on any machine (without Python previously installed on it)?
After further research (I tried in an empty Win 7 x64 bit VM, without any VCredist previously installed), it seems that these files are enough:
the program itself, test.exe (produced by cython --embed and compilation with cl.exe)
python37.dll
python37.zip coming from packages named "Windows x86-64 embeddable zip file" in https://www.python.org/downloads/windows/
vcruntime140.dll, as mentioned in Can I bundle the Visual Studio 2015 C++ Redistributable DLL's with my application? or ask the user to install vc_redist.x64.exe before
ucrtbase.dll
more than 30 files api-ms-win-*.dll were required too; if not you will have the following error:
... api-ms-win-crt-runtime-l1-1-0.dll is missing ...
Notes:
if you require another library, like pygame, just copy/paste the folder from C:\Python37\Lib\site-packages\pygame seems to work
for me, concrt140.dll, msvcp140.dll, vccorlib140.dll did not seem necessary
Useful to test all this: Prevent a Python-embedded to look in my default path C:\Python38 for modules.
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
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>
I already have MSVC++ 2010 Express installed, and my vcvarsall.bat file is at C:\Program Files\Microsoft Visual Studio 10.0\VC, which is in my system PATH. When I run easy_install, it can't find vcvarsall.bat.
Is there something I need to set in my distutils.cfg file to point it to my MSVC++ installation?
G:\>easy_install hg-git
install_dir C:\Python26\Lib\site-packages\
Searching for hg-git
Best match: hg-git 0.2.6
Processing hg_git-0.2.6-py2.6.egg
hg-git 0.2.6 is already the active version in easy-install.pth
Using c:\python26\lib\site-packages\hg_git-0.2.6-py2.6.egg
Processing dependencies for hg-git
Searching for dulwich>=0.6.0
Reading http://pypi.python.org/simple/dulwich/
Reading http://samba.org/~jelmer/dulwich
Reading http://launchpad.net/dulwich
Best match: dulwich 0.7.1
Downloading http://www.samba.org/~jelmer/dulwich/dulwich-0.7.1.tar.gz
Processing dulwich-0.7.1.tar.gz
Running dulwich-0.7.1\setup.py -q bdist_egg --dist-dir c:\docume~1\mlin\locals~1
\temp\easy_install-fhraep\dulwich-0.7.1\egg-dist-tmp-qozily
error: Setup script exited with error: Unable to find vcvarsall.bat
I'd still like to know where to set that reference to vsvarsall.bat...
Well, as martineau wrote you have to have either Visual Studio 2008 or Visual C++ Express installed. Having said that I understand you would like to know where Python looks for this batch file. You can see this by looking at definition of find_vcvarsall function in distutils/msvc9compiler.py standard module. Python checks in turn if any of folders saved in the registry under keys
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VCExpress\9.0\Setup\VC\ProductDir
(for 64bit Windows) or
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\9.0\Setup\VC\ProductDir
(for 32bit Windows) exists and if so it treats such folder as the one containing vcvarsall.bat file. If none of these folders exists Python checks if there's environment variable VS90COMNTOOLS. If this variable exits Python treats folder two levels above value of this variable as the folder containing vcvarsall.bat file.
See also my other answer which explains why you can't use MSVC++ 2010 to build extensions for Python 2.6
EDIT:
The VC++ 2008 files are now packaged in an installer from MS which can be downloaded here. Once installed vcvarsall.bat will be in C:\Users\username\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
Met same problem on python 3.9.12 (anaconda),I install Visual C++ for Python at
C:\Users\UserName\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
and find the msvc9compiler.py at
C:\Users\UserName\anaconda3\Lib\distutils
showed
VS_BASE = r"Software\Microsoft\VisualStudio%0.1f"
how to point the vcvarsall.bat to python ?
(I added the system PATH but not working at all.)
C:\Users\UserName\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
May you please point out how to add registry for the value?
I did't find HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
in my PC.