Using cmake with enthought for python wrapping - python

I recently started trying to switch to canopy from ipython notebooks, which I switched to from MATLAB. I am working towards getting a matlab-like experience for development and research.
I am doing most of these setups cross-platform, but I am starting on OS X.
I have been attempting to install packages for use in canopy, some of which require compilation such as SimpleITK and VTK6.0. I had these both successfully installed in my regular python2.7 installation, but I'm having some trouble installing them for canopy. Right now, Im working on recompiling SimpleITK/Superbuild with CMAKE to recreate the python wrappers. It asks for your python executable, include dir, and python lib location. I found the python executeable from sys.executable from within canopy, and the include dir with 'mdfind -name Python.h, which turned out to be the default location, I used the default python lib.
These were
executeable: /Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/python
Include: /System/Library/Frameworks/Python.framework/Headers
Lib: /usr/lib/libpython2.7.dylib
But I get the following error upon make:
AssertionError: Filename /Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/os.py does not start with any of these prefixes: ['/Users/jmerkow/Library/Enthought/Canopy_64bit/User', '/Library/Python/2.7/site-packages', '/Users/jmerkow/Library/Enthought/Canopy_64bit/User/Extras/lib/python', '/Users/jmerkow/Library/Python/2.7/site-packages', '/Users/jmerkow/.local/lib/python/2.7/site-packages', '/Users/jmerkow/Library/Python/2.7/lib/python/site-packages']
ERROR
-- Installing numpy from /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy to /numpy
ERROR
/bin/sh: ../Testing/Installation/PythonVirtualenv/bin/python: No such file or directory
make[5]: *** [lib/_SimpleITK.so] Error 127
make[4]: *** [Wrapping/CMakeFiles/SimpleITK_PYTHON.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [SimpleITK-prefix/src/SimpleITK-stamp/SimpleITK-build] Error 2
make[1]: *** [CMakeFiles/SimpleITK.dir/all] Error 2
make: *** [all] Error 2
Also, anyother tips to help me get this done are very welcome
EDIT BELOW
So I attempted to compile using:
/System/Library/Frameworks/Python.framework/Versions/Current/bin/python
/System/Library/Frameworks/Python.framework/Versions/Current/include/python2.7/
/System/Library/Frameworks/Python.framework/Versions/Current/lib/libpython2.7.dylib
This compiled and created and egg file named
SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg
but I get the following error when I use enpkg
Traceback (most recent call last):
File "/Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/enpkg", line 10, in
sys.exit(main())
File "/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/enstaller/main.py", line 702, in main
reqs.append(Req(name + ' ' + version))
File "/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/enstaller/resolve.py", line 32, in init
raise Exception("Not a valid requirement: %r" % req_string)
Exception: Not a valid requirement: 'SimpleITK 0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg'
with easy_install I get this error:
Processing SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg
removing '/Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg' (and everything under it)
creating /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg
Extracting SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg to /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages
SimpleITK 0.7.0.dev88-ge297c is already the active version in easy-install.pth
Installed /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg
Processing dependencies for SimpleITK==0.7.0.dev88-ge297c
Searching for SimpleITK==0.7.0.dev88-ge297c
Reading cant post
Reading cant post
Reading cant post
No local packages or download links found for SimpleITK==0.7.0.dev88-ge297c
error: Could not find suitable distribution for Requirement.parse('SimpleITK==0.7.0.dev88-ge297c')
It looked like I installed it, so I tried to import:
import SimpleITK
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

You have configure SimpleITK to use your system python executable, library and include files. However, you are trying to run with the Canopy distribution. They are not binary compatible and the mismatch caused that type of program termination.
You canopy python executable was correctly found:
/Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/python
But you need to make the PYTHON_INCLUDE_DIR and PYTHON_LIBRARY consistent. Try the following commands to help you determine the correct path:
find /Users/jmerkow/Library/Enthought/Canopy_64bit/ -name Python.h
find /Users/jmerkow/Library/Enthought/Canopy_64bit/ -name lib python*.dylib

Related

How do I install hunspell on windows10?

I'm new to python and need help with getting hunspell installed on my windows 10. The tool is PyCharm.
First I tried to install CyHunspell: pip install CyHunspell and got the following error msg:
RuntimeError: 'pkg-config' is not recognized as an internal or external command,operable program or batch file.
Then I tried installing PyHunspell instead and got the following error msg:
ERROR: Could not find a version that satisfies the requirement PyHunspell (from versions: none)
ERROR: No matching distribution found for PyHunspell
Then I tried installing hunspell directly and got the following error msg:
hunspell.cpp
hunspell.cpp(20): fatal error C1083: Cannot open include file: 'hunspell.hxx': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
In my test code:
import hunspell
Result:
spellchecker = hunspell.HunSpell() failed with the following error msg:
AttributeError: module 'hunspell' has no attribute 'HunSpell'
I would think I'm not the first one who uses hunspell on windows 10, but somehow I can't seem to find info needed to get this to work.
The GNU Emacs documentation states here (underlined by me):
The EZWinPorts project provides many useful ports of recent versions of GNU and Unix software. This includes all the optional libraries used by Emacs (image libraries, libxml2, GnuTLS), RCS, Texinfo, a clone of man command, Grep, xz, bzip2, bsdtar, ID Utils, Findutils, Hunspell, Gawk, GNU Make, Groff, GDB.
You will indeed find Hunspell in the list of files of the EZWinPorts project on sourceforge.
Once unzipped, you shall find the executable hunspell.exe inside the bin folder. No installation required. The tool is to be used on the command-line. You probably should add it to your Windows Path.
Tested on my Windows 10 PC. 

not able to install netCDF4 in python without HDF5

i have been trying to install the python package for netcdf4 using the package provided in
ftp://ftp.unidata.ucar.edu/pub/netcdf/
i have installed the netcdf-4.3.3.1.zip
extracted it and followed the instructions given in
https://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Quick-Instructions.html
2.1 Building NetCDF Without HDF5
If you don't want netCDF-4/HDF5, then build like this:
./configure --prefix=/home/ed/local --disable-netcdf-4
make check install
(Replace “/home/ed/local” with the name of the directory where netCDF is to be installed.)
i replaced '/home/ed/local' with '/usr/lib/python2.7/dist-packages'
after this i ran the command ' nc-config --version'
netCDF 4.3.3.1
but i am not able to import the module in python i am geting that
ImportError: No module named netCDF4
nor i am able to find any folder related to netcdf4 in /usr/lib/python2.7/dist-packages
i just need to read the .nc file data if their is any other way help me
thank you
EDIT -------
i realised that you require hdf5 so i got the package
then when i follow the instructions given in the link
when i run the instructions for hdf5 folder i got some errors related to conversion of dos files to unix i fixed them by saving them with ending in unix/linux . but i did not do all the files as after the first two files there where no errors
then i use the commands
make
sudo make install
i get multiple output as
make[1]: Entering directory `/home/akhil/hdf5-1.8.16/src'
Makefile:972: .deps/H5.Plo: No such file or directory
Makefile:973: .deps/H5A.Plo: No such file or directory
Makefile:974: .deps/H5AC.Plo: No such file or directory
Makefile:975: .deps/H5Abtree2.Plo: No such file or directory
Makefile:976: .deps/H5Adense.Plo: No such file or directory
and many errors of the same format
so i ignore them since there was no specific error
igo do the commands for netdf4 file
once i do the first command
LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include ./configure -- enable-netcdf-4 --enable-dap --enable-shared --prefix=/usr/local
i get an error
configure: error: Can't find or link to the hdf5 library. Use --disable-netcdf-4, or see config.log for errors.
then i go into the netcdf4 python
i run sudo python setup.py install
error
netCDF4/_netCDF4.c:237:22: fatal error: H5public.h: No such file or directory
#include "H5public.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
help

How to import fontforge to python in windows 7

Environment: Win 7, Python 3.4, Sublime Text 2
I am trying to use fontforge as in following example, by importing fontforge in *.py:
import fontforge
font = fontforge.open('blank.sfd')
...
However, I haven't found any help for win 7 on where (or which subset) to include fontforge binary in my project to make it work. Any ideas, please? Thanks
Edit:
I was trying to build it with pyextension in win 7 as described here:
http://fontforge.org/source-build.html#MS
via cygwin it fails on executing
./configure --enable-pyextension
throwing
checking for gcc
result: no
checking for cc
result: no
checking for cl.exe
result: no
error: in `/cygdrive/c/fontforge':
no acceptable C compiler found in $PATH
Edit 2:
By installing C compiler I've managed to ./configure it but my attempts have failed on executing make install command. I got following error, preceding another countless lines:
Makefile:91: recipe for target '../libfontforge.la' failed
make[1]: *** [../libfontforge.la] Error 1
make[1]: Leaving directory '/cygdrive/c/fontforge/fontforge'
Makefile:28: recipe for target 'fontforge' failed
make: *** [fontforge] Error 2
Install fontforge for windows, then search your install for a fontforge-console.bat, and double-click it. From there you have a python environment that includes fontforge via the command:
ffpython
e.g.:
ffpython yourPythonFontForgeScript.py
You may need to cd to whatever directory has your python script before running that command, or otherwise make sure that the script is in your %PATH%.

Installing PDQ on windows

I am trying to install "pretty damn quick", an analysis tool for Layered Queing networks.
However there seems to be a lot wrong with my system, and switching to Linux is not an option.
Here is what i tried to get the PDQ running:
First try: Python
I installed python2.7 and downloaded the PDQ for python distribution (its in the tarball in the python dir) :
C:\pdq\pdq42\python>python setup.py install
running install
running build
running build_ext
building 'pdq' extension
error: Unable to find vcvarsall.bat
This error stems from the fact that i supposedly dont have a C-compiler. Even though typing g++ gives me:
C:\pdq\pdq42\python>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/rtools/gcc-4.6.3/bin/../libexec/gcc/i686-w64-mingw3
3/lto-wrapper.exe
Target: i686-w64-mingw32
...snipped...
This problem is somehow documented? So i tried going over to Perl. It said there that the compiler comes with Strawberry Perl. So I installed that. Dmake gave me a lot of trouble but in the end I managed to install it.
C:\pdq\pdq42\perl5>perl Makefile.PL
Writing Makefile for pdq
C:\pdq\pdq42\perl5>dmake
Skip blib\lib\pdq.pm (unchanged)
...snipped...
g++.exe: error: MVA_Approx.o: No such file or directory
g++.exe: error: MVA_Canon.o: No such file or directory
g++.exe: error: MVA_Solve.o: No such file or directory
g++.exe: error: PDQ_Build.o: No such file or directory
g++.exe: error: PDQ_Exact.o: No such file or directory
g++.exe: error: PDQ_Globals.o: No such file or directory
g++.exe: error: PDQ_Report.o: No such file or directory
g++.exe: error: PDQ_Utils.o: No such file or directory
dmake: Error code 129, while making 'blib\arch\auto\pdq\pdq.dll'
Gives me new errors, that i cannot fix, since i cannot google them.
As the last resort i try out installing R, since this should work according to the documentation.
install.packages("c:\pdq\pdq_6.0-1.tar.gz",repos=NULL,type="source")
Warning: invalid package 'c:/pdq/pdq_6.0-1.tar.gz'
Error: ERROR: no packages specified
Warning messages:
1: running command '"C:/Programme/R/R-3.0.1/bin/i386/R" CMD INSTALL -l "C:\Programme\R\R-3.0.1\library" "c:/pdq/pdq_6.0-1.tar.gz"' had status 1
2: In install.packages("c:\pdq\pdq_6.0-1.tar.gz", repos = NULL, type = "source") :
installation of package ‘c:/pdq/pdq_6.0-1.tar.gz’ had non-zero exit status
However in this case i don't even know where to start debugging this to get it going.
So I am seeking help from SO. My question is:
Where did I go wrong and what can I do to find additional information leading to identify the problem? I would really like to have PDQ installed.

Problem installing Shoutpy + Boost.python on opensolaris

Im trying to install shoutpy on opensolaris 2009.6. It relies on boost.python. i've installed the boost_devel libraries from blastwave and linked /opt/csw/include/boost to /usr/include/boost . But when I try to easy_install shoutpy I get the following output
munderwo#opensolaris-test1:/usr/include$ pfexec easy_install shoutpy
Searching for shoutpy
Reading http://pypi.python.org/simple/shoutpy/
Reading http://dingoskidneys.com/shoutpy/
Best match: shoutpy 1.0.0
Downloading http://dingoskidneys.com/shoutpy/shoutpy-1.0.0.tar.gz
Processing shoutpy-1.0.0.tar.gz
Running shoutpy-1.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-w7XQfv/shoutpy-1.0.0/egg-dist-tmp-k11Dky
In file included from /usr/include/boost/python/object/make_instance.hpp:9,
from /usr/include/boost/python/object/make_ptr_instance.hpp:8,
from /usr/include/boost/python/to_python_indirect.hpp:11,
from /usr/include/boost/python/converter/arg_to_python.hpp:10,
from /usr/include/boost/python/call.hpp:15,
from /usr/include/boost/python/object_core.hpp:12,
from /usr/include/boost/python/args.hpp:25,
from /usr/include/boost/python.hpp:11,
from shoutpy.cc:26:
/usr/include/boost/python/object/instance.hpp:44: error: a casts to a type other than an integral or enumeration type cannot appear in a constant-expression
/usr/include/boost/python/object/instance.hpp:44: error: '->' cannot appear in a constant-expression
/usr/include/boost/python/object/instance.hpp:44: error: `&' cannot appear in a constant-expression
In file included from /usr/include/boost/python/converter/registry.hpp:9,
from /usr/include/boost/python/converter/registered.hpp:8,
from /usr/include/boost/python/object/make_instance.hpp:10,
from /usr/include/boost/python/object/make_ptr_instance.hpp:8,
from /usr/include/boost/python/to_python_indirect.hpp:11,
from /usr/include/boost/python/converter/arg_to_python.hpp:10,
from /usr/include/boost/python/call.hpp:15,
from /usr/include/boost/python/object_core.hpp:12,
from /usr/include/boost/python/args.hpp:25,
from /usr/include/boost/python.hpp:11,
from shoutpy.cc:26:
/usr/include/boost/python/converter/rvalue_from_python_data.hpp:99: error: '->' cannot appear in a constant-expression
/usr/include/boost/python/converter/rvalue_from_python_data.hpp:99: error: `&' cannot appear in a constant-expression
/usr/include/boost/python/converter/rvalue_from_python_data.hpp:99: error: template argument 1 is invalid
/usr/include/boost/python/converter/rvalue_from_python_data.hpp:99: error: `value' is not a member of `<declaration error>'
error: Setup script exited with error: command '/usr/lib/python2.6/pycc' failed with exit status 1
This is using python2.6, opensolaris 2009.06, boost 1.35.
any help would be great!
Cheers
Mark
Edit - this has been cross posted on serverfault as its a bit hard to classify where the problem domain is. https://serverfault.com/questions/88724/problem-with-opensolaris-boost-python-and-shoutpy
Unfortunately I've never tried to compile shoutpy under OpenSolaris and I don't use it these days. Boost.python requires a lot from its C++ compiler. Use easy_install -b build_directory shoutpy so it'll keep the source code after it fails, then check the C++ compiler Python tries to use against those supported by boost.python.
I tried compiling it on my desktop Linux and it still works after I edit setup.py to link against libboost_python-mt instead of libboost_python which doesn't exist in Ubuntu (there are several libboost_python* depending on Python version and so forth).

Categories

Resources