how to complie numpy to install on 64 bits platform? - python

My system is :win7 64 ultimate +python34(64)+intel 64 chip.
I have installed mingw64 ,please see:
C:\Users\pengsir>d:\mingw\bin\gcc -v
Reading specs from d:/mingw/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.2/specs
COLLECT_GCC=d:\mingw\bin\gcc
COLLECT_LTO_WRAPPER=d:/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.2/lto-wra
pper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-4.8.2/configure --prefix=/opt/windows_64 --with-sysroot=
/opt/windows_64 --libdir=/opt/windows_64/lib64 --mandir=/opt/windows_64/man --in
fodir=/opt/windows_64/info --enable-shared --disable-bootstrap --disable-multili
b --enable-threads=posix --enable-languages=c,c++ --enable-checking=release --wi
th-system-zlib --with-python-dir=/lib64/python2.7/site-packages --disable-libunw
ind-exceptions --enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose --e
nable-java-home --with-java-home=/opt/windows_64/lib64/jvm/jre --with-jvm-root-d
ir=/opt/windows_64/lib64/jvm --with-jvm-jar-dir=/opt/windows_64/lib64/jvm/jvm-ex
ports --with-arch-directory=amd64 --with-antlr-jar='/home/adrien/projects/win-bu
ilds-1.4/slackware64-current/d/gcc/antlr-*.jar' --disable-java-awt --disable-gtk
test --build=x86_64-slackware-linux --host=x86_64-w64-mingw32 --target=x86_64-w6
4-mingw32
Thread model: posix
gcc version 4.8.2 (GCC)
when i install with the command:
d:\Python34\Scripts\pip.exe install numpy
(other message ommitted)
error: Unable to find vcvarsall.bat
How to compile the numpy to install on the python34?
I don't want to install vs2013 ,i like free software,no money to pay for vs2013 ,please teach me to complie numpy to install on 64 bits platform mingw64.

Is there some requirement that you build numpy from source? I have always just installed it (and every other Python package that's troublesome on Windows) from Christoph Gohlke's Unofficial Binaries Page, which has always worked perfectly for me.

As per http://shop.wickeddevice.com/2013/12/11/windows-7-python-virtualenv-and-the-unable-to-find-vcvarsall-bat-error/:
For Python 3.4, download Visual C++ 2010 from http://www.lfd.uci.edu/~gohlke/pythonlibs/.
Install it.
Open Windows explorer (the file browser) and search for the location of ‘vcvarsall.bat’ and cut it to your clipboard.
run regedit from the Windows start key. You will need admin privilges.
Add a registry entry to HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir (64 bit Windows) or
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir (32 bit)
(If these don't work, try replacing VisualStudio with VCExpress
as described in How do I point easy_install to vcvarsall.bat?
Restart cmd and try again.

Related

ImportError _versionhelper when setting up Bloomberg Python API

I am trying to get set up with the Bloomberg Python API. I have been following along with this tutorial. I am able to successfully python -m pip install — index-url=https://bloomberg.bintray.com/pip/simple blpapi, but then when I try to run import blpapi in the Python interpreter, I get the following error. How do I resolve this error (wondering if it has something to due with me using Python 3.8)?
ImportError:
---------------------------- ENVIRONMENT -----------------------------
Platform: Windows-10-10.0.17763-SP0
Architecture: ('32bit', 'WindowsPE')
Python: 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]
Python implementation: CPython
blpapi 64-bit will be loaded from: "C:\blp\API\blpapi_cpp_3.13.1.1\lib\blpapi3_64.dll"
blpapi 32-bit will be loaded from: "C:\blp\API\blpapi_cpp_3.13.1.1\lib\blpapi3_32.dll"
System PATH: (* marks locations where blpapi was found)
"C:\Windows\system32"
"C:\Windows"
"C:\Windows\System32\Wbem"
"C:\Windows\System32\WindowsPowerShell\v1.0\"
"C:\Windows\System32\OpenSSH\"
"C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL"
"C:\Program Files\Intel\Intel(R) Management Engine Components\DAL"
"c:\nx_dll"
"C:\Program Files\nodejs\"
* "C:\blp\API\blpapi_cpp_3.13.1.1\lib"
"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\"
"C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\Scripts\"
"C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\"
"C:\Users\cpage\AppData\Local\Microsoft\WindowsApps"
* "C:\blp\DAPI"
"C:\blp\DAPI\DDE"
"C:\Users\cpage\AppData\Roaming\npm"
"C:\Program Files\Sublime Text 3"
"C:\Users\cpage\AppData\Local\hyper\app-3.0.2\resources\bin"
"C:\Users\cpage\AppData\Local\Programs\Microsoft VS Code\bin"
* "C:\blp\API\blpapi_cpp_3.13.1.1\lib"
blpapi package at: "C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\lib\site-packages"
Current directory: "C:\Users\cpage"
----------------------------------------------------------------------
No module named '_versionhelper'
Could not open the C++ SDK library.
Download and install the latest C++ SDK from:
http://www.bloomberg.com/professional/api-library
If the C++ SDK is already installed, please ensure that the path to the library
was added to PATH before entering the interpreter.
You need to download the python blpapi package having the version matching your C++ lib.
In your case, since your C++ lib is 3.13.1.1, you can download the 3.13.1 python package:
pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi==3.13.1
Just managed to make it run using version blpapi-3.15.2 using C++ API blpapi_cpp_3.15.0.1
To install run:
python -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi
to import use:
import os
with os.add_dll_directory('<...>\blpapi_cpp_3.15.0.1\lib'):
import blpapi
or add '<...>\blpapi_cpp_3.15.0.1\lib' to PATH
The following procedure works out of the box for CPython 2.7 and 3.7. A Bloomberg rep claims he verified it for CPython 3.5 as well:
Download the C++ BLP API from the official Bloomberg repository. If this link breaks, use Bloomberg API Support homepage to find the up-to-date ones.
Unpack the archive to C:\Programs\blpapi_cpp_3.14.3.1
Exit from the shell.
Set the environment variable BLPAPI_ROOT=C:\Programs\blpapi_cpp_3.14.3.1\. Note that the trailing slash is important.
Start a new shell.
Execute python -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi==3.14.0
Check the installation by executing python -c "import blpapi", which should pass without displaying messages.

Installing pygraphviz on Windows 7 x64 for Python 3.5 x32 failing with fatal error LNK1120: 1 unresolved externals [duplicate]

I am trying to install pygraphviz on Windows 10. There are many solutions to this problem online, but none have yet worked for me. The precise problem I'm having is with this via jupyter notebook-->
[1] import networkx as nx
import pylab as plt
from networkx.drawing.nx_agraph import graphviz_layout
[2]G = nx.DiGraph()
G.add_node(1,level=1)
G.add_node(2,level=2)
G.add_node(3,level=2)
G.add_node(4,level=3)
G.add_edge(1,2)
G.add_edge(1,3)
G.add_edge(2,4)
nx.draw(G, pos=graphviz_layout(G), node_size=1600, cmap=plt.cm.Blues,
node_color=range(len(G)),
prog='dot')
plt.show()
I get the following errors after [2]:
ModuleNotFoundError Traceback (most recent call last)
C:\Users\name\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py
in
pygraphviz_layout(G, prog, root, args)
254 try:
--> 255 import pygraphviz
256 except ImportError:
ModuleNotFoundError: No module named 'pygraphviz'
and
ImportError Traceback (most recent call last)
<ipython-input-2-86a15892f0f0> in <module>()
9 G.add_edge(2,4)
10
---> 11 nx.draw(G, pos=graphviz_layout(G), node_size=1600, cmap=plt.cm.Blues,
12 node_color=range(len(G)),
13 prog='dot')
C:\Users\name\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py in graphviz_layout(G, prog, root, args)
226
227 """
--> 228 return pygraphviz_layout(G,prog=prog,root=root,args=args)
229
230 def pygraphviz_layout(G,prog='neato',root=None, args=''):
C:\Users\name\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py in pygraphviz_layout(G, prog, root, args)
256 except ImportError:
257 raise ImportError('requires pygraphviz ',
--> 258 'http://pygraphviz.github.io/')
259 if root is not None:
260 args+="-Groot=%s"%root
ImportError: ('requires pygraphviz ', 'http://pygraphviz.github.io/')
Here's what I've tried to resolve this
(1) Regular pip install: "pip install pygraphviz" This is the error I get at the end. EDIT I get the same error even if I run cmd as admin.
Command "C:\Users\name\Anaconda3\python.exe -u -c "import setuptools,
tokenize;__file__='C:\\Users\\name~1\\AppData\\Local\\Temp\\pip-build-
n81lykqs\\pygraphviz\\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\name~1\AppData\Local\Temp\pip-
b3jz1lk5-record\install-record.txt --single-version-externally-managed --
compile" failed with error code 1 in C:\Users\name~1\AppData\Local\Temp\pip-
build-n81lykqs\pygraphviz\
(2) Downloading and installing graphviz-2.38.msi, and then downloading both the 64-bit versions of the wheel. This is the result.
C:\Users\name\Anaconda3>pip install pygraphviz-1.3.1-cp34-none-
win_amd64.whl
pygraphviz-1.3.1-cp34-none-win_amd64.whl is not a supported wheel on this
platform.
C:\Users\name\Anaconda3>pip install pygraphviz-1.3.1-cp27-none-
win_amd64.whl
pygraphviz-1.3.1-cp27-none-win_amd64.whl is not a supported wheel on this
platform.
What I would like to try, but am not sure how to do properly:
Edit setup.py. I have read a lot about people finding solutions in changing the paths, but I'm not really sure how to do this. This method looks very complex.
Thank you for any help/insight!
Updated the repo: [GitHub]: CristiFati/Prebuilt-Binaries - (master) Prebuilt-Binaries/PyGraphviz/v1.5:
Using official Graphviz 2.42.2 sources
.whls (win_amd64, win32) for currently supported Python versions
Newer versions might be added (check one level up)
For Python 2.7, they are already built: [UCI.LFD]: Unofficial Windows Binaries for Python Extension Packages - PyGraphviz, an interface to the Graphviz graph layout and visualization package..
Notes:
In some (I guess, most of the) cases, a Graphviz installation will be required on the system where PyGraphviz runs on, because PyGraphviz uses some of Graphviz's tools (executables). They can be downloaded, or built (they don't have to match PyGraphviz architecture (032bit (PC032), 064bit (PC064)), as they are invoked). Update: I also added Graphviz 2.42.2 build (PC032 - as it works on both PC064 and PC032 Win) in the above repository
Check it for newer software versions
Also, a bug (present in previous versions) was fixed. Check [SO]: pygraphviz 1.5 default edge no arrow? (#CristiFati's answer) for more details
Anyone who wants to know more details about the build process, read on!
1. Intro
Almost 2 years later, and the problem (well, not exactly as in the question) still persists.
I want to start by emphasizing the difference between the 2 packages:
[PyPI]: pygraphviz - Download files: the one in question
[PyPI]: graphviz - Download files: (a simpler) one with a similar name
In Anaconda environment, [SO]: Installing PyGraphviz on Windows 10 64-bit, Python 3.6 (#TomHanks's answer) works perfectly.
PyGraphwiz only has available for download an archive (.zip, in this case) file, meaning that it contains (C / C++) sources.
A couple of words about packages (.whls) whose names contain things like cp34-none-win_amd64 (check [SO]: What does version name 'cp27' or 'cp35' mean in Python? (#WayneWerner's answer) for details):
They contain binaries (.so or .pyd (.dll)), which are linked against a specific Python library
They are meant to work only with that Python version (so 34 is not meant to work with Python 3.6)
Even is one somehow "outsmarts" PIP and manages to install such a package (it's not that hard, actually), it will fail at import time, or worse, it has a high probability of crashing Python
Now, many packages have prebuilt binaries for most common Python versions running on various OSes (e.g. [PyPI]: mysql-connector-python - Download files), but just as many don't, and those only contain sources. Unfortunately, PyGraphviz is in the 2nd category. For the latter ones, pip install will:
Download the sources
Build the sources locally
A C (C++) compiler is required, typically:
GCC on Nix
VStudio on Win
They might have other dependencies
Install the built artefacts (binaries and .py(c) files)
As a side note: pip -v ... enables verbose mode for the current command, which comes in extremely handy when experiencing install errors.
Back to our problem: Python 3.6 needs VStudio 2015 ([Python.Wiki]: WindowsCompilers).
This is a very vast topic, I covered some parts in:
[SO]: Simstring (python) installation in windows (#CristiFati's answer)
[SO]: How to build a DLL version of libjpeg 9b? (#CristiFati's answer)
You should check them before proceeding and also keep them open, as you will definitely need them in the next steps.
I have VStudio 2015 Community (among many other versions) installed, you should install it too, it's free ([MS.VStudio]: Still want an older version?).
PyGraphviz depends on [Graphviz]: Graph Visualization Software. So, at build time it will need (parts of) Graphviz (which also has other dependencies of its own) to be already built. Unfortunately, I couldn't find prebuilt binaries (there is [Graphviz]: Windows Packages - graphviz-2.38.zip, but that's not helping), so it will have to be built manually.
Before going further:
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811]> "e:\Work\Dev\VEnvs\py_064_03.06.08_test0\Scripts\python.exe" -c "import pygraphviz"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pygraphviz'
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811]> dir /b
other
src
This is my top dir, any sources are downloaded in the src dir, binaries will be placed in the bin dir.
2. Build Graphviz
Before starting, I want to mention that I heavily rely on Cygwin (you don't have to, there are also other variants (MSYS2)), and some of my tools are installed there, so I'll be alternating between Cygwin and Cmd terminals (which might be confusing).
[Graphviz]: Graphviz Build Instructions for Windows states:
For building on Windows:
(Graphviz versions ≥ 2.41)
First, in the root of the repository, perform git submodule update --init. This will download all submodules, which are mostly the dependencies for the Windows build. Next, add the windows\dependencies\graphviz-build-utilities directory to your PATH (and restart Visual Studio or the prompt with which you execute msbuild after that). This folder contains the tools Bison, Flex and SED (and future additions) with versions that are tested. If all went right, the dependencies are now set up and you can build Graphviz.
First, we need to download everything:
[cfati#cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q045093811/src/graphviz]> ~/sopr.sh
### Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ###
[064bit prompt]> git clone https://gitlab.com/graphviz/graphviz.git .
Cloning into '.'...
remote: Enumerating objects: 71728, done.
remote: Counting objects: 100% (71728/71728), done.
remote: Compressing objects: 100% (19331/19331), done.
remote: Total 71728 (delta 52200), reused 71681 (delta 52157)
Receiving objects: 100% (71728/71728), 163.79 MiB | 480.00 KiB/s, done.
Resolving deltas: 100% (52200/52200), done.
Checking out files: 100% (3870/3870), done.
[064bit prompt]>
[064bit prompt]> git submodule update --init
Submodule 'dependencies/criterion' (https://github.com/Snaipe/Criterion.git) registered for path 'dependencies/criterion'
Submodule 'windows/dependencies/graphviz-build-utilities' (https://github.com/ErwinJanssen/graphviz-build-utilities.git) registered for path 'windows/dependencies/graphviz-build-utilities'
Submodule 'windows/dependencies/libraries' (https://github.com/ErwinJanssen/graphviz-windows-dependencies.git) registered for path 'windows/dependencies/libraries'
Cloning into '/cygdrive/e/Work/Dev/StackOverflow/q045093811/src/graphviz/dependencies/criterion'...
Cloning into '/cygdrive/e/Work/Dev/StackOverflow/q045093811/src/graphviz/windows/dependencies/graphviz-build-utilities'...
Cloning into '/cygdrive/e/Work/Dev/StackOverflow/q045093811/src/graphviz/windows/dependencies/libraries'...
Submodule path 'dependencies/criterion': checked out '301d143ea42c024f22b673b69c72a4cb3c8d151f'
Submodule path 'windows/dependencies/graphviz-build-utilities': checked out '050fff84ce195e0740878748760fd801eeb07b23'
Submodule path 'windows/dependencies/libraries': checked out '141d3a21be904fa8dc2ae3ed01d36684db07a35d'
[064bit prompt]>
[064bit prompt]> git show head
commit 89292b5945933b1501293c04894ed9cf886241be (HEAD -> master, origin/master, origin/HEAD)
Merge: 429d43615 97811bd35
Author: Stephen C North <scnorth#gmail.com>
Date: Mon Feb 4 08:09:40 2019 -0500
Merge branch 'wasbridge/graphviz-master' into HEAD
[064bit prompt]> git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
You'll end up with a dir that contains ~320 MiB of stuff. The dir contains a graphviz.sln file, which is a VStudio (2015) solution file which contains 63 projects.
Looking at the Anaconda or Python 2.7 PyGraphviz (built) package, it only depends on cgraph.dll, which in turn depends on cdt.dll, so only the 2 projects are relevant to us. Note that these 2 projects might not need all the Git submodules (so the dir might be trimmed down), but I didn't investigate further.
Unfortunately, the projects are only configured for 032bit (Win32 platform (pc032)). The 064bit one must be manually added (I did it from VStudio IDE - and also described the process in one of my answers that I referenced). After saving the projects, they will be shown as modified by Git:
[064bit prompt]> git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: lib/cdt/cdt.vcxproj
modified: lib/cgraph/cgraph.vcxproj
modified: windows/dependencies/graphviz-build-utilities (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
The 3rd item is because I needed to reset some security permissions on 2 executables (used when building cgraph):
bison.exe
flex.exe
which were not set properly (most likely, because of Cygwin).
You can build the 2 projects from IDE, but I chose command line ([MS.Docs]: MSBuild command-line reference) since I find it more flexible:
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811]> sopr.bat
### Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ###
[prompt]> "c:\Install\x86\Microsoft\Visual Studio Community\2015\vc\vcvarsall.bat" x64
[prompt]> set PATH=%PATH%;%CD%\src\graphviz\windows\dependencies\graphviz-build-utilities
[prompt]> msbuild src\graphviz\lib\cdt\cdt.vcxproj /t:Rebuild /p:Platform=x64;Configuration=Release;SolutionDir=%CD%\src\graphviz\;OutDir=%CD%\bin\Win\dynamic\064\UCRTv140\md\Release\graphviz\ >build_cdt_064.txt 2>&1
[prompt]> echo %errorlevel%
0
[prompt]> dir /b
bin
build_cdt.txt
other
src
[prompt]> msbuild src\graphviz\lib\cgraph\cgraph.vcxproj /t:Rebuild /p:Platform=x64;Configuration=Release;SolutionDir=%CD%\src\graphviz\;OutDir=%CD%\bin\Win\dynamic\064\UCRTv140\md\Release\graphviz\ >build_cgraph_064.txt 2>&1
[prompt]> echo %errorlevel%
0
[prompt]> dir /b "bin\Win\dynamic\064\UCRTv140\md\Release\graphviz"
cdt.dll
cdt.dll.lastcodeanalysissucceeded
cdt.exp
cdt.lib
cgraph.dll
cgraph.dll.lastcodeanalysissucceeded
cgraph.exp
cgraph.lib
So, we have everything needed (2 .lib and 2 .dll files) in order to go on.
3. Build PyGraphviz
PyGraphviz sources are (downloaded from [GitHub]: pygraphviz/pygraphviz - (pygraphviz-1.5) pygraphviz-pygraphviz-1.5.zip and) unpacked in src/pygraphviz/pygraphviz-pygraphviz-1.5.
One more adjustment is needed to Graphviz (probably it's done as part of another project - an install step): preparing the header files:
[prompt]> mkdir include\graphviz
[prompt]> copy src\graphviz\lib\cdt\cdt.h include\graphviz
1 file(s) copied.
[prompt]> copy src\graphviz\lib\cgraph\cgraph.h include\graphviz
1 file(s) copied.
Unfortunately, PyGraphviz does not build OOTB, because of [GitHub]: pygraphviz/pygraphviz - Python 3 support. To fix that, [GitHub]: eendebakpt/pygraphviz - Workaround for PyIOBase_Type for Python2 on win must be applied. I adapted it to work with the current sources (as it doesn't work OOTB, as well :X( ) for graphviz_wrap.cpp only:
pygraphviz-1.5-all-pyiobase_b85d12ac22d39063f7dbcc396e825c563431e352.patch:
--- pygraphviz/graphviz_wrap.c.orig 2018-09-10 16:07:12.000000000 +0300
+++ pygraphviz/graphviz_wrap.c 2019-02-26 18:05:20.281741400 +0200
## -2988,7 +2988,18 ##
#if PY_VERSION_HEX >= 0x03000000
-extern PyTypeObject PyIOBase_Type;
+static PyObject *PyIOBase_TypeObj;
+
+static int init_file_emulator(void)
+{
+ PyObject *io = PyImport_ImportModule("_io");
+ if (io == NULL)
+ return -1;
+ PyIOBase_TypeObj = PyObject_GetAttrString(io, "_IOBase");
+ if (PyIOBase_TypeObj == NULL)
+ return -1;
+ return 0;
+}
#endif
## -3449,7 +3460,7 ##
{
#if PY_VERSION_HEX >= 0x03000000 || defined(PYPY_VERSION)
#if !defined(PYPY_VERSION)
- if (!PyObject_IsInstance(obj0, (PyObject *)&PyIOBase_Type)) {
+ if (!PyObject_IsInstance(obj0, PyIOBase_TypeObj)) {
PyErr_SetString(PyExc_TypeError, "not a file handle");
return NULL;
}
## -3523,7 +3534,7 ##
{
#if PY_VERSION_HEX >= 0x03000000 || defined(PYPY_VERSION)
#if !defined(PYPY_VERSION)
- if (!PyObject_IsInstance(obj1, (PyObject *)&PyIOBase_Type)) {
+ if (!PyObject_IsInstance(obj1, PyIOBase_TypeObj)) {
PyErr_SetString(PyExc_TypeError, "not a file handle");
return NULL;
}
## -6051,6 +6062,12 ##
SWIG_InstallConstants(d,swig_const_table);
+#if PY_VERSION_HEX >= 0x03000000
+ if (init_file_emulator() < 0) {
+ return NULL;
+ }
+#endif
+
PyDict_SetItemString(md,(char*)"cvar", SWIG_globals());
SWIG_addvarlink(SWIG_globals(),(char*)"Agdirected",Swig_var_Agdirected_get, Swig_var_Agdirected_set);
SWIG_addvarlink(SWIG_globals(),(char*)"Agstrictdirected",Swig_var_Agstrictdirected_get, Swig_var_Agstrictdirected_set);
That is a diff (patch). See [SO]: Run/Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (#CristiFati's answer) (Patching UTRunner section) for how to apply patches on Win (basically, every line that starts with one "+" sign goes in, and every line that starts with one "-" sign goes out).
[prompt]> :: Restore the original prompt as cwd is important
[prompt]> exit
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811]> set _TOP_DIR=%CD%
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811]> pushd src\pygraphviz\pygraphviz-pygraphviz-1.5
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811\src\pygraphviz\pygraphviz-pygraphviz-1.5]> pushd pygraphviz && "c:\Install\x64\Cygwin\Cygwin\AllVers\bin\patch.exe" -p 1 -buNi ..\pygraphviz-1.5-all-pyiobase_b85d12ac22d39063f7dbcc396e825c563431e352.patch && popd
patching file graphviz_wrap.c
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811\src\pygraphviz\pygraphviz-pygraphviz-1.5]> echo %errorlevel%
0
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811\src\pygraphviz\pygraphviz-pygraphviz-1.5]> "e:\Work\Dev\VEnvs\py_064_03.06.08_test0\Scripts\python.exe" setup.py install --include-path=%_TOP_DIR%\include --library-path=%_TOP_DIR%\bin\Win\dynamic\064\UCRTv140\md\Release\graphviz >%_TOP_DIR%\install_pygraphviz_064.txt 2>&1
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811\src\pygraphviz\pygraphviz-pygraphviz-1.5]> echo %errorlevel%
0
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811\src\pygraphviz\pygraphviz-pygraphviz-1.5]> popd
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811]> set PATH=%PATH%;%CD%\bin\Win\dynamic\064\UCRTv140\md\Release\graphviz
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q045093811]> "e:\Work\Dev\VEnvs\py_064_03.06.08_test0\Scripts\python.exe" -c "import pygraphviz;print(dir(pygraphviz), \"\n\", pygraphviz.graphviz._graphviz)"
['AGraph', 'Attribute', 'DotError', 'Edge', 'ItemAttribute', 'Node', '__all__', '__author__', '__builtins__', '__cached__', '__date__', '__doc__', '__file__', '__license__', '__loader__', '__name__', '__package__', '__path__', '__revision__', '__spec__', '__version__', 'absolute_import', 'agraph', 'division', 'graphviz', 'print_function', 'release', 'test', 'tests', 'version']
<module '_graphviz' (e:\Work\Dev\VEnvs\py_064_03.06.08_test0\lib\site-packages\pygraphviz\_graphviz.cp36-win_amd64.pyd)>
As seen, the module was successfully imported.
As a remark, the 2 .dll dependencies (from previous section) must be available when the module is imported, so their dir is added to %PATH%.
Of course this is only a (lame) workaround (gainarie), this shouldn't happen every time one has to work with the package.
I don't know (yet) how to instruct setup.py to also copy them in the package build / install dir, so as an alternative (also workaround) one has to manually copy them in PyGraphviz install dir (next to _graphviz.cp36-win_amd64.pyd, which is (in my case): "e:\Work\Dev\VEnvs\py_064_03.06.08_test0\lib\site-packages\pygraphviz").
4. Shortcut
Since the whole process is complex and requires lots of manual interventions and hacks, I've managed to build (with minor setup.py modifications) the (.whl) package.
I am not aware of a simple way to make it publicly available, so (although maybe it's not the best practice,) I uploaded it at [GitHub]: CristiFati/Prebuilt-Binaries - (master) Prebuilt-Binaries/PyGraphviz/v1.5/pygraphviz-1.5-cp36-cp36m-win_amd64.whl.
Notes:
The following is regarding PyGraphviz, but it can be generalized and applied to any (.whl) package
Also, the GitHub repository will be used as an example, but (again) it can apply to (.whls in) any repository, including [PyPI]: The Python Package Index (I'm not using the PyGraphviz one as it has no binaries, but for example [PyPI]: numpy 1.17.0 - Download files)
You can download it locally (e.g. in C:\Path\to\downloaded), then install it like (this is one way, check [SO]: How to install a package for a specific Python version on Windows 10? (#CristiFati's answer) for alternatives):
"C:\Path\to\Python-3.6-amd64\python.exe" -m pip install "C:\Path\to\downloaded\pygraphviz-1.5-cp36-cp36m-win_amd64.whl"
The above .whl is located next to several others. Those are for different Python versions (and that happens when the .whl contains .dlls (.pyds) or .sos (on Nix) that link to a specific Python library). To match your Python version search the .whl name for cp${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}. In the current situation, it's cp36 corresponding to Python 3.6, but the same principle applies for other Python versions (cp37, cp38, cp39, cp310, cp311, ...). Check [SO]: What does version name 'cp27' or 'cp35' mean in Python? for more details.
Same thing for the architecture (win_amd64 / win32 (x86_64 / i686 on Nix)).
Note: It works for Anaconda environments as well!
The most voted answers seemed to be installing graphviz, rather than pygraphviz.
If you are using a conda environment, you may try using this channel:
conda install graphviz pygraphviz -c alubbock
I tried it out with networkx 2.1, it worked fine.
Here's what worked for me:
Win 7 AMD64
Install MSFT C++ compiler.
Install Anaconda for Win AMD64, Python3.
Install graphviz for Win.
Add C:\Program Files (x86)\Graphviz2.38\bin to your PATH environment variable.
Download pygraphviz-1.3.1-cp34-none-win_amd64.whl.
Create a Conda environment with Python version 3.4: conda create --name digraphs python=3.4 anaconda.
Enter the environment: activate digraphs.
Install pygraphviz using pip: pip install pygraphviz-1.3.1-cp34-none-win_amd64.whl.
Run example: python ./gviz_simple.py.
Exit the environment: deactivate
I put some stuff up on github about it. It's messy, use at your own risk:
https://github.com/darkhipo/Easy-Digraph-Draw
Solved it on Windows 10 64-bits and Python 3.6.
Steps:
Download Graphviz for windows from the graphiviz site.
Add the Graphviz bin path C:\Program Files (x86)\Graphviz2.38\bin in your Windows path.
Close and reopen your terminals so the path changes is recognized.
Download the graphviz python 3.6 wheel.
Install the graphviz wheel.
pip install graphviz-0.8.3-py2.py3-none-any.whl
Done!

Building Qscintilla2 python bindings on Windows7 with MinGW (PyQt4.11, Qt4.8.6)

I've tried to resolve this prolem for about 3days, and I'd finally felt that I need to ask for help by creating my own question.
I have Windows 7x64 and Qt4.8.6 installed.
I need Python with PyQt and Qscintilla2 to be installed and working.
Now I wil describe my last actions. I did everything like included packages instructions said.
1) Installed Python2.7.9 32bit from official website.
2) Downloaded SIP from here (dev snapshot), then:
configure.py —platform win32-g++
mingw32-make
mingw32-make install
3) Downloaded PyQt from here (not the installer but dev snapshot, cause I need to build with MinGW and istaller producec MSVC version), then:
configure-ng.py -spec win32-g++
mingw32-make
mingw32-make install
Ater these steps I tested PyQt on my project - everything works fine.
Then I starded trying to install Qsnitilla2.
4) Downloaded Qsnitilla2 from here (dev snapshot), then:
a) in Qt4Qt5 folder:
qmake qscintilla.pro -spec win32-g++
mingw32-make
mingw32-make install
This had installed Qsnitilla2 in Qt4.8.6 as I saw;
b) in Python folder( F..ing Python bindngs, excuse my french):
config.py —spec win32-g++
mingw32-make
after this I got ld.exe error (linking error):
Then, afted doing some research, I manually edited my Makefile.Release (by adding -lpython27 to LIBS parameter):
LIBS = -L"c:\Qt-mingw\4.8.6\lib" -LC:\Python27\libs -LC:\Qt-mingw\4.8.6\lib -lqscintilla2 -lQtGui4 -lQtCore4 -lpython27
After this, my mingw32-make completed succesfully. So:
mingw32-make install
This had installed Qscintilla2 Python bindings.
Now I can see Qsci autocomlplete in Eclipse.
So i've tried this:
from PyQt4.Qsci import QsciScintilla
And i've got this in traceback:
from PyQt4.Qsci import QsciScintilla
ImportError: DLL load failed: Не найден указанный модуль
(Translation: The specified module could not be found)
I've tried this with both dev snapshot and src packages from Riverbank website. And also with MinGW 4.8.1 and MinGW-w64 4.8.4. I can't use MinGW-w64 over 4.8 version cause I need boost-1.55 and it only supports MinGW 4.8.
I don't know what to do now, but I really want to use Scintilla in my project. So i'll be very gratefull for any suggestions.
Have you ever tried to load the QsciScintilla right from the console? I mean you need to enter the directory where the QScintilla located( this means current folder is the default folder), then try run the command "from PyQt4.Qsci import QsciScintilla", if this load module failure still happens, this possibly means you need extra dynamic which QScintilla depends, you need to use dll dependency to find out if some other libraries were missing, then put the missing libraries into the same folder of QsciScintilla.

Loading matplotlib on cygwin

To load matplotlib on cygwin, I have:
Loaded pre-requisites using cygwin 64-bit setup: pkg-config, freetype2, libfreetype-devel, libpng-devel, gtk2.0, libgtk2.0-devel
Downloaded the matplotlib tar file (http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.3.1/matplotlib-1.3.1.tar.gz) and changed the source code to get around the "_tri" error as advised here:
matplotlib error while installing pyspeckit
Then built and installed matplotlib:
$ python setup.py build
$ python setup.py install
And am down to what looks like a matplotlib backend error. Does anyone know how to get around this:
/usr/lib/python2.7/site-packages/gtk-2.0/gtk/init.py:57: GtkWarning: could not open display
...
cursors.MOVE : gdk.Cursor(gdk.FLEUR),
et n RuntimeError: could not create GdkCursor object
EDIT: I just finally got it and matplotlib is finally working on cygwin. To do this, I did:
From cygwin setup, loaded the X-Server tools:
xorg-server xinit
From cygwin setup, I also loaded these so that use telnet or ssh connections to run remote X clients:
inetutils openssh
I set my display:
DISPLAY=":0.0"
export DISPLAY
From the cygwin shell, I did:
$ startxwin
Then I ran my python scripts which use matplotlib in the X-window
I had an issue with "python setup.py build" not finding the ft2build.h which comes from the the freetype2 package. I installed the freetype2 development package and I can find it in /usr/include/freetype2/ft2build.h but the error is still there.
After digging into the setupext.py at the function check_include_file(include_dirs, filename, package), I noticed that the package="freetype2" was not concatenated into to the search path. Hence it could not find "/usr/include/ft2build.h" when it should be "/usr/include/freetype2/ft2build.h
Fixing this line #134
if not has_include_file(include_dirs, "%s/%s"%(package,filename)):

pylucene install makefile error

When I build the pylucene environment, I meet this problem.
I don't know how to config the makefile of it on Windows platform.
Someone help me, if there is any example about building pylucene on Windows.
The cmd shows that:
can not find tools.jar
makefile213:recipe for target 'ivy' failed.
make:***【ivy】error 1
Here is the makefile:
VERSION=3.6.1-2
LUCENE_SVN_VER=HEAD
LUCENE_VER=3.6.1
LUCENE_SVN=http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_6_1
PYLUCENE:=$(shell cd)
LUCENE_SRC=lucene-java-$(LUCENE_VER)
LUCENE=$(LUCENE_SRC)/lucene
# Windows (Win32, Python 2.7, Java 1.6, ant 1.8.1, Java not on PATH)
SHELL=cmd.exe
PYLUCENE:=$(shell cd)
ANT=D:\ant183\bin\ant
JAVA_HOME=C:\\Program Files\\Java\\jdk1.7.0_01
PREFIX_PYTHON=D:\\Python27
PYTHON=$(PREFIX_PYTHON)\python.exe
JCC=$(PYTHON) -m jcc.__main__
NUM_FILES=3
$(LUCENE_JAR): $(LUCENE)
cd $(LUCENE) && $(ANT) -Dversion=$(LUCENE_VER)
OS=$(shell uname)
BUILD_TEST:=$(PYLUCENE)\build\test
I had similar error when installing on opensuse 13.2, the way to work around is to install ivy independently before trying to build pylucene.

Categories

Resources