Cython with python 3.3 - python

I have been using python 3.3
This is an old problem as I searched, and this is what I did:
helloworld.pyx
print("Hello world!")
Then, in ipython, I did:
import pyximport; pyximport.install()
import helloworld
It says:
ImportError: Building module helloworld failed: ["ValueError:
['path']\n"]
The same problem did not happen with python 2.7
I googled this: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
and realized that I have to install Windows SDK for Windows 7 and .NET Framework 4. As it comes with the VC++2010 Redistributables, I did not install the redistributables alone again. I thought I had everything ready, but the import error still remains.
Could anyone please help me solve it?
Thank you!
-Shawn

install Windows 7 SDK, then open cmd run:
"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /Release /x64
then run:
python setup.py install

I was having the same issue and the same environment (win7 64bit, python-3.3.3 64bit).
I have
installed the Windows 7 SDK as described on the wiki cython wiki as you did,
applied the patch (msvccompiler9_33.diff) from this python bug,
fixed the above patch by defining a missing variable as described here
Installed MS Visual C++ Express 2010 (seems to be required)
Updated the Windows 7 SDK to include the "Windows Headers and Libraries", "Tools" and of course the "Visual C++ Compilers" the MSVC++2010 redistributable.
And now I can compile and import the helloworld.py just fine.

Related

clang.cindex.LibclangError "Undefined symbol clang_CXXRecord_isAbstract"

I am trying to execute clang 5.0 with the next commands but it does not work.. I typed:
import clang
import clang.cindex
clang.cindex.Config.set_library_file('/usr/lib/x86_64-linux-gnu/libclang-5.0.so.1')
id = clang.cindex.Index.create()
and I received the following error:
clang.cindex.LibclangError: /usr/lib/x86_64-linux-gnu/libclang-5.0.so.1: undefined symbol: clang_CXXRecord_isAbstract. Please ensure that your python bindings are compatible with your libclang.so version.
I am using clang-5.0 with the bindings from https://github.com/llvm-mirror/clang
Windows
I haven't tested this right now, but it worked a month ago for me.
Either download the src code from github and go to /bindings/python/ and copy the clang directory and paste it into your python site packages dir or (try both) pip install clang-5
Download the llvm binares. If you have python-32bit then install llvm 32bit!! Otherwise it wont work. For 64bit python install the 64bit binaries
In your python program just import clang.cindex as cl and in your code do cl.Config.set_library_file("your/path/to/libclang.dll")
libclang.dll should be in your clang/bin installation directory
Linux
Running it right now, so it works for me
pip3 install clang-5
from your package manager either get llvm-clang or llvm-clang-32bit
depending on your python installation
In your python program just import clang.cindex as cl and in your code do cl.Config.set_library_file("your/path/to/libclang.so")
From my experience libclang.so should be located in either /usr/lib32/ or usr/lib64/
Hope this helps!

Import scip to python

I've tried unsuccessfully to get scip running with python. I'm using Yosemite (10.10.3), python 2.7 and have installed scip optimization suit (http://scip.zib.de/download.php?fname=scipoptsuite-3.1.1.tgz) with make.
I can start scip after the installation via the terminal.
sages-MBP:~ sage$ scip SCIP version 3.1.1 [precision: 8 byte] [memory: block] >[mode:optimized][LP solver: SoPlex 2.0.1] [GitHash: bade511]
But when I try to use import scip in python there appears the message
No module named scip
The same error message appears for from zibopt import scip
If I print the system path with print sys.path in python, the folder scipoptsuite-3.1.1/scip-3.1.1/bin is included where the file
scip-3.1.1.darwin.x86_64.gnu.opt.spx is situated.
Is it possible that the reason for the error message is that I haven't linked correctly necessary libraries?
Or which folders have to be included in the pythonpath to get scip working?
I Hope someone can help me out!
You need to install the python interface that comes with SCIP. Go to scip/interfaces/python/ and read the instructions in README and INSTALL. This interface is using Cython to communicate with the C-Code of SCIP.
make will only install the native Linux or Mac binaries/libraries.
The environment variable DYLD_LIBRARY_PATH needs to be set to contain the lib/ directory of the SCIPoptSuite installation (see comment by #саша)

Trouble installing scikit-bio on Windows

When attempting to install the scikit-bio toolkit via pip on Windows XP using Python 2.78 and Visual C++ 2008 Express Edition, the process is interrupted with the following message issued by VC:
cl : Command line error D8021 : invalid numeric argument '/Wno-error=declaration
-after-statement'
Concerning this error, Microsoft Developer Network website just says:
invalid numeric argument 'number'
A number greater than 65,534 was specified as a numeric argument.
I did not (yet) attempted to install scikit-bio under Linux (Ubuntu 12.04 Precise), but I am under the impression that it will work fine (as everything goes as regards Linux).
Has anyone ever succeeded installing scikit-bio under Windows (XP, 7, 8)? Any hints?
Thanks in advance!
I've installed Anaconda's Python (3.5) on a Windows 10 machine. As you should know, there is no official version of scikit-bio for this platform, but you can install it with this workaround:
Download the latest source from the Scikit-bio Github repository.
Using a tool like 7-zip, unzip it at your home directory.
Open a command line client and change to the source's directory
cd %HOMEPATH%\scikit-bio-master
Using Notepad++ edit the file setup.py
"C:\Program Files (x86)\Notepad++\notepad++" setup.py
Look for the line where the ssw_extra_compile_args variable is defined and change it. You can comment the previous version and redefine the variable in a new line:
#ssw_extra_compile_args = ['-Wno-error=declaration-after-statement']
ssw_extra_compile_args = []
Save the changes, close the editor and run the installation with this command:
python setup.py install
Hopefully you won't receive any error messages. Open an Anaconda's Python session (using the command python) and test if Scikit-Bio was installed rightly using print(skbio.art).
By the way, I've previously installed Visual Studio 2015 Community Edition with C++ SDK features enabled, in order to meet the compiler requirements for the package (Scikit-Bio) installation.
At this time, scikit-bio doesn't officially support windows. We'd definitely be interested in hearing about people's efforts to install, test, and use scikit-bio on Windows, but we don't have developers with expertise in this area.
This is related to biocore/skbio#941.

Installing Mapnik 2.2.0 in windows 7 with Python 2.7

I've been trying to install mapnik on my computer for hours but what i always get when I import mapnik is ImportError: DLL load failed: The specified procedure could not be found.
I'm using Windows 7. The currently installed software is Geoserver from Opengeo suite.
Here is my path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jdk1.7.0_45\bin;C:\Python27;C:\mapnik-v2.2.0\lib
My python path:
C:\Python27;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Program Files\ArcGIS\bin;C:\\mapnik-v2.2.0\python\2.7\site-packages\;C:\mapnik-v2.2.0\bin\;
Follow the install instructions
First ensure you have 32 bit python 27 installed.
You can do this by typing the following into a python shell
>>> import platform
>>> platform.architecture()
('32bit', 'WindowsPE')
If you see '64bit', try reinstalling python with the 32bit version (look for the "Python 2.7.5 Windows Installer" link).
After that,
Download the mapnik package (I tested it with the full SDK version)
Extract the archive to C:\mapnik-v2.2.0
Add C:\mapnik-v2.2.0\lib; and C:\mapnik-v2.2.0\bin; to your PATH
Add C:\mapnik-v2.2.0\python\2.7\site-packages; to your PYTHONPATH
import mapnik
I had the same issue on WinServewr 2008 R2. The solution I found is to install Microsoft Visual C++(x86) redistributable package 10.0.40219, because mapnik depends on it. This package comes with postgreSQL 9.3 x86, so when you install only Postgre x64 version you can have this error.
I had this problem as well, even after I installed a 32-bit Python. I was getting the same error:
ImportError: DLL load failed: The specified procedure could not be found.
What fixed it in the end was copying all the DLLs to my python executable directory. I assume there was some DLL-hell type action going on and it was linking to a DLL somewhere with the same name but without that entrypoint. What entrypoint it was looking for I do not know.
In the end it was all useless though because it turns out that there is no OSM (OpenStreetMaps) plugin for the 2.2.0 version, so I decided to do this on Linux instead.
See the table at https://github.com/mapnik/mapnik/wiki/WindowsInstallation for the reference of a missing OSM plugin - execution results in a runtime error indicating the plugin could not be loaded.
I think Windows binary support for mapnik has been dropped so I don't expect much change here.

JPype installation on Mountain Lion: "error: command 'gcc' failed with exit status 1" [duplicate]

I am trying to use Neo4j for a project, and want to interface with it through Python since I'm a newbie to programming and don't know any Java. I'm following the installation instructions, but I'm stuck on
the first step, which is to install JPype.
I'm using OS X 10.7 (lion). I think my configuration is pretty standard
with Python 2.7.2 downloaded from the Python website and Java 1.6.0 downloaded from the Apple website.
When I run
% sudo python setup.py install
On the JPype installer, I get about a 100 lines of error code about various .h files, then it
terminates with the lines:
lipo: can't figure out the architecture type of: /var/tmp//
ccwOzLi9.out
error: command 'gcc-4.2' failed with exit status 1
I found a blog post about a gcc error with JPype, but I followed the instructions there to no avail. I also emailed the author of that post, and he told me had never actually used JPype, had been working in OS X 10.6, and didn't have any insight.
I also emailed the creator of JPype, who told me that he only uses Windows, and has no idea how to make the install work on OS X. But if we can solve this, I can point him to the answer and maybe he can add the solution to the JPype documentation and help lots of other people as well!
So, anyone know what I'm doing wrong? I would like to use Neo4j, but I
don't know Java so I'm at a complete loss for how to fix a compiler
error.
Based on reading every Google result available, my two running
theories are that:
I'm somehow using a 32-bit version of Python or of Java (though I
used standard official installations and can't figure out how to
switch to 64-bit or if that's even possible)
The JPype files can only be compiled using GCC 4.0 instead of 4.2.
But I can't find anything online about how to rollback to GCC 4.0 (or
if it comes shipped with 2011 MacBooks and there is some way to force
JPype to compile with that instead).
There is another similar question, but the solution there is to use a different adapter that goes through REST instead of hooking directly into Java. I will try that if I have to, but I would really rather use the recommended Neo4j method if it's possible.
I'm not a Python guy, but tried installing JPype on my machine:
% uname -a
Darwin fatty-i7.local.tld 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
% java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
On OSX Lion, the latest JDK appears to be located here:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/JavaVM.framework/
A little googling turned up this post: http://blog.y3xz.com/post/5037243230/installing-jpype-on-mac-os-x
I followed those instructions to modify setup.py, then ran sudo python setup.py install with no problems.
Does that help?
On my Lion, the "include" directory in the JDK was gone, so JPype couldn't find jni.h.
I updated setup.py in two places, one to set where to find jar libraries:
def setupMacOSX(self):
self.javaHome = '/System/Library/Frameworks/JavaVM.framework'
self.jdkInclude = ""
self.libraries = ["dl"]
self.libraryDir = [self.javaHome+"/Home/lib"]
self.macros = [('MACOSX',1)]
And one to set where to find jni.h:
def setupInclusion(self):
self.includeDirs = [
self.javaHome+"/Headers",
<other stuff>
For me,
self.javaHome = '/System/Library/Frameworks/JavaVM.framework/Versions/Current/'
worked.
$ uname -a Darwin 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr 9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64
$ java -version java version "1.6.0_33" Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720) Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)
Here are directions I put in my README to install JPype on OS X 10.7. Same idea as the answers here but different enough to warrant the submission.
The python interface to java (JPype) needs mods to the setup.py:
In summary, you need to make sure the JPype setup.py script can see your Java SDK "Headers" and "Home" directory
I had to install Java from Apple first since my default OS X installation did not come with Headers in the typical Java install path which I found by executing:
/usr/libexec/java_home
If you do happen to have a Headers dir, you probably do not need to reinstall Java and can set the path vars below based on your java HOME directory which is likely different from those in these directions
After I installed Java, I found the new installation in:
/Library/Java/JavaVirtualMachines/
My Home directory was:
/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/
and my Header directory was:
/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Headers/
1) The JPype script assumes that Headers is within the Home directory but it's not, so I changed the Home path var and created a new Content path var in the setup.py script - In setupMacOSX(self):
self.javaHome = '/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/'
self.javaContents = '/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/'
2) In setupMacOSX(self), change self.libraryDir:
self.libraryDir = [self.javaContents + "/Libraries"]
Note that this step was mentioned as required but I did not have to do this for it to work so maybe try without it first
3) In setupInclusion, add paths to your "Home/include" dir and your "Headers" dir:
self.javaHome+"/include",
self.javaContents + "/Headers",
4) Running the installation should now work:
sudo python setup.py install
For everyone who is still trying to install Jpype but has meanwhile updated Mac OS: Andreas Kolleger's answer just works fine, but with XCode 4.3 the path changed to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/JavaVM.framework/Versions/Current/
In ML it's MacOSX10.8.sdk. At least on my system. :)
For me, on Mountain Lion
self.javaHome = '/System/Library/Frameworks/JavaVM.framework/'
worked.
$uname -a
Darwin 12.0.0 Darwin Kernel Version 12.0.0: Sun Jun 24 23:00:16 PDT 2012; root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64
$ java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)
I did the same, but choosing
self.javaHome = '/Developer/SDKs/**MacOSX10.6.sdk**/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/'
instead
self.javaHome = '/Developer/SDKs/**MacOSX10.7.sdk**/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/'
realize that I use version 6 vs 7. With the 7 version I got the same errors that the beginning.
To make Will's answer a bit more specific: I had to modify the setupInclusion(self) method by adding the directory path he suggested, ie, '/System/Library/Frameworks/JavaVM.framework/Headers' on Mountain Lion (java version 1.6). With that the installation of JPype succeeded (though gave a bunch of warnings...)
Here's what worked for me - recommend you put the first line in your profile.
export JAVA_HOME=$(/usr/libexec/java_home)
cd $JAVA_HOME
sudo ln -s include Headers
sudo cp include/darwin/* include/
cd -
Note that instead of changing setup.py, I'm changing my JDK install. This has the advantage of fixing the issue for other projects.
For those trying to install on Mountain Lion, I had to further edit the setup.py file to include the header files here:
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers

Categories