Apologies in advance for what is probably a bad/poorly phrased question, but I merely dabble in programming and am very unfamiliar with under the hood aspects of package installation, etc.
Basically, I am trying to install the pygrib package (available here: https://github.com/jswhit/pygrib) via a cygwin terminal.
I am running Python 2.7.3 32-bit on Windows 10.
Originally I encountered the missing vcvarsall.bat error the first time I tried to run 'python seteup.py build' and followed the advice here: error: Unable to find vcvarsall.bat
After installing the MS Visual Studio package, I have made it past that error and to another I do not understand with the following output:
$ python setup.py build
reading from setup.cfg...running build
running build_py
running build_ext
skipping 'pygrib.c' Cython extension (up-to-date)
building 'pygrib' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Users\Matthew\Anaconda2\lib\site-packages\numpy\core\include -I/usr/local\include -I/usr/local\include -I/usr/local\include/jasper -I/usr/local\include -I/usr\include -I/usr\include -Ig2clib_src -IC:\Users\Matthew\Anaconda2\include -IC:\Users\Matthew\Anaconda2\PC /Tcpygrib.c /Fobuild\temp.win32-2.7\Release\pygrib.obj
pygrib.c
c:\users\matthew\anaconda2\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
pygrib.c(242) : fatal error C1083: Cannot open include file: 'grib_api.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
Obviously it's still looking for some other files, or needs other environment variables defined, but I'm at a loss as to how to proceed and I'm far from an expert when it comes to any of this.
I'd also be glad to try something completely different if you have a better way to go about this process entirely.
I have tried pip and the conda installer, but have not had any luck with them either.
Thank you in advance for anything you can offer.
Better to use linux on virtual machine within Windows ten. Then you can install pygrib without pain. As you are trying to play with meteorological data, it is recommended to install Linux and it will help you at may places. There is even Anaconda has a package (only for Linux and Mac). You can install using:-
conda install -c conda-forge pygrib=2.0.1
For your specif case following link might be useful:-
https://github.com/jswhit/pygrib/issues/19
https://github.com/jswhit/pygrib/pull/18 and https://github.com/conda-forge/ecmwf_grib-feedstock/issues/5
Gud luck.
for python 3 i needed to install it directly with linux package manager
sudo apt-get install python3-grib
To use: pip install pygrib
you need to install python3-grib:
sudo apt install python3-grib
NOTE:
Ubuntu Linux:
python3-grib requires libeccodes-dev
if later you install libgrib-api-dev it requires libgrib-api-dev.
which is not compatable with libgrib-api-dev
Meaning, if you install libgrib-api-dev after you install python3-grib you break the python3-grib installation.
Take me a while also, but this way was very simple and efficient. I then installed it on pycharm.
and on anaconda with
pip install pyproj
pip install pygrib
I am using Anaconda on Windows 10.
I have accessed Anaconda Prompt for the environment that I wanted to install the package.
In there, I have started by installing pyproj:
pip install pyproj
And then:
conda install -c conda-forge pygrib
Related
I am on a windows 10 machine and recently moved from python 2.7 to 3.5. When trying to install lxml through pip, it stops and throws this error message-
building 'lxml.etree' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
I have a working copy of VS 2015 installed. When I try to install the visual cpp tools through that link, it says that Microsoft Visual Studio 2015 is already installed on the machine. I also tried installing visual studio c++ 2015 redistributables, both 64 and 32 bit versions, but both of them say that there's another version of the product already installed.
typing set in the command prompt includes this -
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
Which means that the path is set.
This is probably the only resource I could find on SO, but the answer suggests rolling back to Python 3.4.3 from 3.5. Has anybody resolved problems of this kind?
Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
EDIT: I managed to install it using the precompiled binary (Thanks Paul), but I would still like to know what's causing this.
Have you checked that when you installed Visual Studio, you installed the C++ compiler? It seems like a silly question, but this is the mistake I made. Check by going into the setup for visual studio (Programs and features: Modify "Visual Studio 2015"), then under Programming Languages->VC++, make sure it's ticked.
Run pip install wheel
Download lxml from http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml, if your python version is 3.5 , download lxml-3.6.4-cp35-cp35m-win32.whl.
Run python -m pip install lxml-3.6.4-cp35-cp35m-win32.whl
As an update to the answer from #davidsheldon above, if you want to use Visual Studio Build Tools 2017 instead of 2015, it will work.
I found that the default install of the build tools stand alone was not enough, however, I added `VC++ 2015.3 ... toolset for desktop (x86,x64) and then python was happy:
I've found another solution to get through this:
Because I use anaconda python, so I use this code:
conda install -c conda-forge scrapy
I have same question with you! I found a way no need install vs2015,maybe,you just haven't install twisted.http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted .download twisted --version(Twisted‑17.5.0‑cp36‑cp36m‑win_amd64.whl)(maybe win_amd32.whl if 64didn't work),and run : pip PATH + filename
pip install C:\Users\CR\Downloads\Twisted-17.5.0-cp36-cp36m-win_amd64.whl
pip install Scrapy
I just install successful! good luck for you!
my step to insatll scrapy:
1.pip install wheel
2.pip install lxml
3.pip install pyOpenSSL
4.pip install Twisted (fault->do like above)
5.install pywin32 form : https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/
6.pip Scrapy (succesful)
Had the same problem and noticed that I had installed the 32bit version in a 64bit machine. All I did was uninstall the wrong one and install the right version and it worked fine.
Easiest way to achieve this, can be automated as it doesn't require user input:
python -m pip install https://download.lfd.uci.edu/pythonlibs/archived/lxml-4.9.0-cp311-cp311-win_amd64.whl
This will install the 64-bit version on your machine.
First:
pip install wheel
Second: go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
and download proper wheel.
pip install the file you downloaded (.whl).
I'm trying to install Dlib with the following comand - "pip install dlib", but at the end of installation I`ve received an error:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\Koco\\AppData\\Local\\Temp\\pip-install-ge96cojw\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Koc
o\\AppData\\Local\\Temp\\pip-install-ge96cojw\\dlib\\build\\lib.win-amd64-3.7', '-DPYTHON_EXECUTABLE=C:\\Users\\Koco\\PycharmProjects\\untitled\\venv\\Scripts\\python.exe', '-DCMAKE_LIBR
ARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Koco\\AppData\\Local\\Temp\\pip-install-ge96cojw\\dlib\\build\\lib.win-amd64-3.7', '-A', 'x64']' returned non-zero exit status 1.
----------------------------------------
Command "C:\Users\Koco\PycharmProjects\untitled\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Koco\\AppData\\Local\\Temp\\pip-install-ge96cojw\\dlib\\se
tup.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\Koco\AppData\Local\Temp
\pip-record-j0ufhjqu\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Koco\PycharmProjects\untitled\venv\include\site\python3.7\dlib" failed wi
th error code 1 in C:\Users\Koco\AppData\Local\Temp\pip-install-ge96cojw\dlib\
I`ve installed "cmake" already.
Hi guys I found a solution on this problem.
1. Easyest way is to install Visual Studio and all packages for C++ or only the package for Dlib - this should slove the problem.
On this link https://github.com/ageitgey/face_recognition/issues/175#issue-257710508 can be find detail descriprion for installation from "masoudr".
I will put the installation guide bellow:
"Hi,
I've successfully installed and tested this tool on my windows 10 machine and I'm writing a simple procedure to install it. It may be useful for some people try to use this tool on a Windows machine.
IMPORTANT: Actually this project has made for Linux systems and especially dlib. In my tests, the performance of this tool in Windows 10 was about a quarter in comparison with Ubuntu built with the same specs. But I haven't seen any difference between these two in other subjects.
Read First:
The new version of dlib doesn't need Boost anymore so you can skip it. Remember that you still need to meet the following requirements.
Requirments:
(I've used this tutorial with these tools installed on Windows 10 but the newer versions may work too.)
Microsoft Visual Studio 2015 (or newer) with C/C++ Compiler installed. (Visual C++ 2015 Build Tools didn't work for me and I got into problems in compiling dlib)
Boost library version 1.63 or newer. Also, you can use precompiled binaries for specific MSVC you have but I don't suggest. (I've included the compiling procedure of Boost in this tutorial)
Of course Python3 (I used Python3.5 x64 but the other versions may work too)
CMake for windows and add it to your system environment variables.
Installation:
Easy installation:
Just install dlib and face_recognition (not always on newest version):
pip install dlib and then pip install face_recognition.
Manual installation:
Download and install scipy and numpy+mkl (must be mkl version) packages from this link (all credits goes to Christoph Gohlke). Remember to grab the correct version based on your current Python version.
Download Boost library source code or binary release for your current MSVC from this link.
If you downloaded the binary version skip to step 4 else follow these steps to compile and build Boost by yourself:
3-1. Extract the Boost source files into C:\local\boost_1_XX_X (X means the current version of Boost you have)
3-2. Create a system variable with these parameters:
Name: VS140COMNTOOLS
Value: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\ (or any path where you have installed MSVC)
3-3. Open Developer Command Prompt for Visual Studio and go to the current directory of Boost extracted and try these commands to compile Boost:
bootstrap
b2 -a --with-python address-model=64 toolset=msvc runtime-link=static
3-4. If you successfully compile Boost, it should create compiled files in stage directory.
(If you have already compiled Boost skip this step) If you already download the binary release just extract the contents to C:\local\boost_1_XX_X
Grab latest version of dlib from this repo and extract it.
Go to dlib directory and open cmd and follow these commands to build dlib: (remember to replace XX with the current version of Boost you have)
set BOOST_ROOT=C:\local\boost_X_XX_X
set BOOST_LIBRARYDIR=C:\local\boost_X_XX_X\stage\lib
python setup.py install --yes USE_AVX_INSTRUCTIONS or python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
Now you can use import dlib without any problem in your python script.
You can also check the current version of dlib with pip show dlib.
Now simply install face_recognition with pip install face_recognition.
Enjoy!
Finally, I need to say thanks to #ageitgey and #davisking for their awesome work."
I am trying to install TA-Lib for Python 3.7. I've already read through a number of solutions, but have come to a point I can't figure out. Here is the message I get from pip:
Collecting ta-lib
Using cached https://files.pythonhosted.org/packages/90/05/d4c6a778d7a7de0be366bc4a850b4ffaeac2abad927f95fa8ba6f355a082/TA-Lib-0.4.17.tar.gz
Requirement already satisfied: numpy in c:\python37_64\lib\site-packages (from ta-lib) (1.15.4)
Installing collected packages: ta-lib
Running setup.py install for ta-lib: started
Command "c:\python37_64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Todd\\AppData\\Local\\Temp\\pip-install-0c2__0gf\\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\Todd\AppData\Local\Temp\pip-record-3dpfanca\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Todd\AppData\Local\Temp\pip-install-0c2__0gf\ta-lib\
Running setup.py install for ta-lib: finished with status 'error'
Complete output from command c:\python37_64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Todd\\AppData\\Local\\Temp\\pip-install-0c2__0gf\\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\Todd\AppData\Local\Temp\pip-record-3dpfanca\install-record.txt --single-version-externally-managed --compile:
C:\Users\Todd\AppData\Local\Temp\pip-install-0c2__0gf\ta-lib\setup.py:79: UserWarning: Cannot find ta-lib library, installation may fail.
warnings.warn('Cannot find ta-lib library, installation may fail.')
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\talib
copying talib\abstract.py -> build\lib.win-amd64-3.7\talib
copying talib\deprecated.py -> build\lib.win-amd64-3.7\talib
copying talib\stream.py -> build\lib.win-amd64-3.7\talib
copying talib\test_abstract.py -> build\lib.win-amd64-3.7\talib
copying talib\test_data.py -> build\lib.win-amd64-3.7\talib
copying talib\test_func.py -> build\lib.win-amd64-3.7\talib
copying talib\test_pandas.py -> build\lib.win-amd64-3.7\talib
copying talib\test_stream.py -> build\lib.win-amd64-3.7\talib
copying talib\__init__.py -> build\lib.win-amd64-3.7\talib
running build_ext
building 'talib._ta_lib' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\talib
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\python37_64\lib\site-packages\numpy\core\include -Ic:\ta-lib\c\include -Ic:\python37_64\include -Ic:\python37_64\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tctalib/_ta_lib.c /Fobuild\temp.win-amd64-3.7\Release\talib/_ta_lib.obj
_ta_lib.c
talib/_ta_lib.c(524): fatal error C1083: Cannot open include file: 'ta_libc.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
FINISHED
Thanks.
Here is what works for me...
Download TA_Lib-0.4.10-cp27-cp27m-win_amd64.whl from here
And use command pip install TA_Lib-0.4.10-cp27-cp27m-win_amd64.whl
I was using Conda4 with python 3.6 64 bit version.
Another way also you can try
To install Ta-Lib with Python 3.6+, Windows 64 bit use this pip install -i https://pypi.anaconda.org/masdeseiscaracteres/simple ta-lib
The root cause of the error is probably because you haven't installed actual TA-Lib library which is written in C. Note that the python lib is just a wrapper on top of the actual library. So in order to have python wrapper successfully installed, you'll need to install its prerequisite (the actual TA-Lib).
See https://github.com/mrjbq7/ta-lib#dependencies for more details.
From above reference (for ease of access) :
Installing actual TA-Lib (prerequisite for python wrapper) :
Windows
Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib
Move the Unzipped Folder ta-lib to C:\
Download and Install Visual Studio Community 2015 if already not installed (Remember to Select [Visual C++] Feature)
open x64 Native Tools Command Prompt
navigate to C:\ta-lib\c\make\cdr\win32\msvc
type nmake (this command builds the library)
Linux
$ tar -xzf ta-lib-0.4.0-src.tar.gz
$ cd ta-lib/
$ ./configure --prefix=/usr
$ make
$ sudo make install
Mac OS X
$ brew install ta-lib
If you are using a M1 laptop and Homebrew, then you can set these before installing:
export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include"
export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib"
Hint : It seems, by default, the setup.py reads actual library files from C:\ta-lib (in Windows) and /usr (in Linux). so if you move the downloaded zip file to another location and extract it there (for Windows) or set ./configure --prefix to any location other than /usr (for Linux), then you would have to set TA_LIBRARY_PATH and TA_INCLUDE_PATH environment variables to your desired locations.
If you installed the underlying TA-Lib library with a custom prefix (e.g., with ./configure --prefix=$PREFIX), then when you go to install this python wrapper you can specify additional search paths to find the library and include files for the underlying TA-Lib library using the TA_LIBRARY_PATH and TA_INCLUDE_PATH environment variables:
$ export TA_LIBRARY_PATH=$PREFIX/lib
$ export TA_INCLUDE_PATH=$PREFIX/include
$ python setup.py install # or pip install ta-lib
The documentation of Ta-lib package here is well clear:
https://github.com/mrjbq7/ta-lib
https://mrjbq7.github.io/ta-lib/
And as it was clearly mentionned! this python ta-lib library! Is a wrapper for the TaLib library at https://ta-lib.org/
This is a Python wrapper for TA-LIB based on Cython instead of SWIG
To know the ta-lib.org library is a library created in c lang! You can check here
And multiple binding and interfaces are made for different languages! Just as mentionned in the official website!
The python library is a binding for python that use cython! Which make it more efficient then SWIG!
Know that I'll insist on using pip! (it works all well and it's convenient)
For the installation to go well! You'll need to go in two steps! You need to install TaLib native library binaries first! Then install the python lib with pip (again with pip)! And this order is necessary! You can't go for installing the python binding before the first installation finish!
All that said!
Installation
Step 1: Installing Talib native binary
Installing the Ta-lib software (Or native library binary)! Is a must! And need to be done first!
Follow the instructions here:
https://github.com/mrjbq7/ta-lib#dependencies
The instructions are too clear and detailed!
(Linux users you need to execute the command with the right privelege (hince using sudo))
And last thing! You can check #Code_Worm answer in this thread here He explained many points highly well aboutt the instruction above !
I'll pin point too his hint:
Hint : It seems, by default, the setup.py reads actual library files from C:\ta-lib (in Windows) and /usr (in Linux). so if you move the downloaded zip file to another location and extract it there (for Windows) or set ./configure --prefix to any location other than /usr (for Linux), then you would have to set TA_LIBRARY_PATH and TA_INCLUDE_PATH environment variables to your desired locations.
Check the section bellow this hint!
You can check the trouble shooting section here
Step 2: Installing the python library using pip
Don't proceed with this step until the first step is successfully finished and done with!
Again the pip package and pip works well! And so no need to use some whl file from any other website and src! I'll show you how!
pip install TA-Lib
However here there is many things to say!
First you need to use python 3
So you may use pip3 instead of pip! If pip is resolving to the python2 version (which is common in linux installations)!
pip3 install TA-Lib
Now you may fall in this problem and error!
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
IF such is the case! That's a problem that can come with python 3.9! (if you are using 3.8 you may not encounter that at all)!
The solution and fix is simple! We have just to make an upgrade to some packages! You can follow the instructions from the answer here:
https://stackoverflow.com/a/65640477/7668448
After some trial and error I upgraded, pip, distlib and setuptools and it solved it. Not sure which of those is causing it. (On the last two I found issues 1 2 of other sites)
It is caused by removing unescape from HTMLParser in python3.9, which seems to break setuptools.
pip3 install --upgrade setuptools
If it does not work, try also:
pip3 install --upgrade pip
pip3 install --upgrade distlib
That's it all! If the first step (step 1: Installing TaLib native binaries) is well done and finished! Then running pip3 install TA-Lib will works well this time!
For Linux users! If you run it with sudo! And it failed! Don't use sudo! You should not!
For linux users you may need to install python headers
sudo apt-get install python3-dev
You can try it only if it didn't works! In most linux distro! You'll be ok by default!
Last (Trouble shooting doc section)
If needed Check the trouble shooting section here
If you didn't installed first TA-lib native library (as mentioned here and installed python ta-lib first it helps to re-install TA-lib using: pip install --upgrade --force-reinstall TA-lib
i would suggest installing using the wheel from here. Recently i ran across the same problems while trying to upgrade the library which is again another thing you wouldn't want to do.
Hope this helps. Good luck.
I want to install parquet for python using pip within an Anaconda 2 installation on Windows 10.
While installing I ran into the error that is described here, the installer can't find snappy-c.h.
There is no mention on how to install this on Windows in the answers.
I downloaded the Snappy library from http://google.github.io/snappy/ and now I'm stuck.
From my error message I would have assumed that the header files need to be in C:\Users\...\AppData\Local\Continuum\Anaconda2\include, but in the downlaoded archive header and library files are just all in the same folder.
How do I install these properly in the Anaconda folder?
Full error message:
Building wheels for collected packages: python-snappy
Running setup.py bdist_wheel for python-snappy ... error
Complete output from command C:\Users\...\AppData\Local\Continuum\Anaconda2\python.exe -u -c "import setup
tools, tokenize;__file__='c:\\users\\...\\appdata\\local\\temp\\pip-build-kl4zef\\python-snappy\\setup.py';f=ge
tattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec
'))" bdist_wheel -d c:\users\...\appdata\local\temp\tmpt8fz9bpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-2.7
copying snappy.py -> build\lib.win-amd64-2.7
running build_ext
building '_snappy' extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Users\...\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nol
ogo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Users\...\AppData\Local\Continuum\Anaconda2\include -IC:\Users\...
\AppData\Local\Continuum\Anaconda2\PC /Tpsnappymodule.cc /Fobuild\temp.win-amd64-2.7\Release\snappymodule.obj
snappymodule.cc
snappymodule.cc(31) : fatal error C1083: Cannot open include file: 'snappy-c.h': No such file or directory
error: command 'C:\\Users\\...\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\V
C\\Bin\\amd64\\cl.exe' failed with exit status 2
After a really long and frustrating time trying different methods to get the C files working, I found this site:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Where C. Gohlke has kindly compiled and uploaded the files for us windows users.
Just download the version you need based on your system and python version. I am using 64bits and python 3.6, so I used the following command from my download folder:
pip install python_snappy-0.5-cp36-cp36m-win_amd64.whl
It worked like a charm :)
It seems there are now Conda packages that should simplify things (in Anaconda). I was able to do (on Python 3.6, Windows 10):
conda install -c conda-forge snappy
conda install -c conda-forge python-snappy
EDIT: Refer to the other answers in this thread, I only keep this up for reference.
Here's the steps it took me to install Snappy and Python-Snappy on Windows 10:
Install cygwin.
Download snappy from http://google.github.io/snappy/ and unpack it somewhere into the cygwin directory.
Write AM_PROG_AR into configure.ac above LT_INIT and run autogen.sh from the cygwin terminal, install missing cygwin packages if needed.
Copy snappy-c.h into the Anaconda2/include folder and libsnappy.a into the Anaconda2/Lib folder (in ~/AppData/Local/Continuum/).
stdint.h was missing for Visual C++ Compiler for Python 2.7., I found it here and put it into ~\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include.
Installing python-snappy should now work without throwing any errors.
If you get problems and weird imports check if the SnapPy library is also installed and deinstall it because it causes a conflict.
(Everything works fine now.)
EDIT: No it does not. This method is not reliable, once you try to update you run into new problems. And installing on Python 3 is another monster that isn't tackled by this solution.
Anybody out there has successfully installed PygraphViz on Windows?
Since there is not an official release for Windows, I'm trying to build it myself, but it fails to compile. I'm not the first one to face this issue, but I could not find an answer.
This is the console output:
C:\Python26\Lib\site-packages\pygraphviz-0.99.1>c:\python26\python.exe setup.py
install
library_path=C:/Program Files/Graphviz2.26.3/lib/debug/dll
include_path=C:/Program Files/Graphviz2.26.3/include/graphviz
running install
running build
running build_py
running build_ext
building 'pygraphviz._graphviz' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG "-IC:/Program Files/Graphviz2.26.3/include/graphviz" -Ic:\python
26\include -Ic:\python26\PC /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win32-2.
6\Release\pygraphviz/graphviz_wrap.obj
graphviz_wrap.c
warning: I don't know what to do with 'runtime_library_dirs': ['C:/Program Files
/Graphviz2.26.3/lib/debug/dll']
error: don't know how to set runtime library search path for MSVC++
Any help would be appreciated!
I appreciate this may be an obsolete thread by now, but to update it for others currently hitting this wall, the installer at Christoph Gohlke's Unofficial Windows Binaries for Python Extension Packages has just worked for me..
Here's what worked for me in Python 2.7. I assume it should work similarly in Python 2.6.
Precondition: Install mingw32 (included in pythonxy distrib if you're using it), Graphviz
1) Download pygraphviz sources
2) Edit setup.py to change paths to smth like
library_path=r"c:\Program Files (x86)\Graphviz 2.28\bin"
include_path=r"c:\Program Files (x86)\Graphviz 2.28\include\graphviz"
Note that it's \bin, not \lib. Linking with libs didn't work for me.
3) run python setup.py build -c mingw32
Result of step 3:
c:\Python27\Lib\site-packages\pygraphviz-1.1>python setup.py build -c mingw32
library_path=c:\Program Files (x86)\Graphviz 2.28\bin
include_path=c:\Program Files (x86)\Graphviz 2.28\include\graphviz
running build
running build_py
running build_ext
building 'pygraphviz._graphviz' extension
C:\MinGW32-xy\bin\gcc.exe -mno-cygwin -mdll -O -Wall "-Ic:\Program Files (x86)\G
raphviz 2.28\include\graphviz" -Ic:\Python27\include -Ic:\Python27\PC -c pygraph
viz/graphviz_wrap.c -o build\temp.win32-2.7\Release\pygraphviz\graphviz_wrap.o
pygraphviz/graphviz_wrap.c: In function 'agattr_label':
pygraphviz/graphviz_wrap.c:2855:5: warning: return makes integer from pointer wi
thout a cast
writing build\temp.win32-2.7\Release\pygraphviz\_graphviz.def
C:\MinGW32-xy\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\py
graphviz\graphviz_wrap.o build\temp.win32-2.7\Release\pygraphviz\_graphviz.def "
-Lc:\Program Files (x86)\Graphviz 2.28\bin" -Lc:\Python27\libs -Lc:\Python27\PCb
uild "-Wl,-Rc:\Program Files (x86)\Graphviz 2.28\bin" -lcgraph -lcdt -lpython27
-lmsvcr90 -o build\lib.win32-2.7\pygraphviz\_graphviz.pyd
4) copy the result from the just built lib.win32-2.7 (single sub-folder called pygraphviz) into your Python's site-packages folder
Enjoy!
I've just ran into the same problem myself today. It isn't much of an answer, but I read in their FAQ:
Q:
How do I compile pygraphviz under
Windows? And why don’t you distribute
a pygraphviz Windows installer?
A:
We don’t have Windows development
machines but would like to have
pygraphviz work on all platforms. If
you have success with Windows or would
be willing to help test and distribute
a Windows installer please drop us a
note.
See also ticket 67:
https://networkx.lanl.gov/ticket/67
This, together with multiple unanswered pleas for help on various forums, mailing lists and newsgroups, lead me to believe that running PyGraphviz on Windows isn't something that can be done simply today.
So I did the next obvious thing (*) and fired up my Ubuntu on top of VirtualBox to create Graphviz graphs with Python. Curiously, it fails to install from source on Ubuntu as well, unless you have Graphviz itself installed from source, but it can be installed from a pre-built package with sudo apt-get python-pygraphviz.
So now I'm a happy pygraphviz user. Or at least 90% happy. PGV shows a os.popen3 deprecation warning on Python 2.6, and a 18-month-old ticket with a patch on this issue still hasn't been incorporated. Argh!
(*) I do it more and more lately...
If you remove the 'runtime_library_dirs' parameter from the extension dictionary in on line 147 in setup.py, your error message goes away. However, it can't find cgraph.lib. If you change your settings to
library_path=r'C:\Program Files\Graphviz2.26.3\lib\debug\lib'
everything complies and installs. You can import the modules, but the moment you try and access anything, it bombs out. In looking at the source for GraphViz, it appears that the windows version is C#/.NET - perhaps that is the source of our problems?
Hat the same problem and I finally got it to work! The problem was actually in Python's msvc9compiler.py (yes you do need VS8's vc9 to compile, too). The error comes on line 698 in the function runtime_library_dir_option(). Instead of having it throw an error, have it return the same string as library_dir_option():
def runtime_library_dir_option(self, dir):
return "/LIBPATH:" + dir
Then compile and it should work.
Alternately, you can try to use easy_install and avoid compiling. I installed "distribute", a fork of easy_install. But it also requires pkg-config, and you either have to compile that or get an older version. Furthermore, you also have to add pkg-config to the application path.
I managed to compile pygraphviz under windows with the following setup:
Windows 7,
WinPython-32bit-2.7.6.3,
Graphviz2.38,
microsoft visual c++ 2008 express edition,
pygraphvize 1.3 dev
in setup.py changed lines 35 and 36 to:
include_dirs = r"C:\Program Files\Graphviz2.38\include"
library_dirs = r"C:\Program Files\Graphviz2.38\lib\release\lib"
The compilation works and you get a working pygraphviz python module.
Hopes this helps.
This works for me, Python 2.7 32 bit, PyGraphViz 2.38, VCForPython27, Windows 10 64 bit.
First, install VCForPython27, see http://aka.ms/vcpython27.
Then, execute the following command, so that distutils.msvc9compiler can find the VC compiler. (This needs Administrator privilege. And if your Windows is 32 bit, you need to adjust the registry key.)
reg add HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\9.0\Setup\VC -v productdir -t REG_SZ -d "%LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0" -f
Finally, install PyGraphViz.
set INCLUDE=C:\Program Files (x86)\Graphviz2.38\include
set LIB=C:\Program Files (x86)\Graphviz2.38\lib\release\lib
pip install pygraphviz