Python-Asurv Installation - python

When I try to install python-asurv using setup.py, (typing "path"\python "path"\setup.py install in the command prompt), I get the following error:
building extension "twokm" sources target build\src.win32-2.7\twokmmodule.c does not exist: Assuming twokmmodule.c was generated with "build_src --inplace" command. error: '.\\twokmmodule.c' missing`
I am on windows 7 64bit with 32bit python2.7
In the zip file that I downloaded, there is setup.py, asurv.py, asurv.pyc, two licences, a readme, and twokm.pyf and twokm.f, which I think are in fortran format (don't know anything about fortran). The README just says type python setup.py install.
I think that for the twokm.pyf and twokm.f files I need to use f2py to convert them to .py files, am I right?
How can I install python-asurv?

Make sure you have installed numpy at it is dependency of python-asurv
Do pip install numpy and then Do python setup.py install in the directory you have downloaded.

Related

Installing shared library with python package not separately

I have successfully built a Python package that uses CMake combined with pybind11 to create a shared object (.so - assuming only Linux usage at the moment) file. The implementation works but I am unable to remove this shared object file using pip uninstall .
My setup command in setup.py file looks like this taken from the pybind/cmake_example repository:
setup(
name='package',
version='0.0.1',
author='-',
author_email='-',
description='A test project using pybind11 and CMake',
long_description='',
ext_modules=[CMakeExtension('packagebindings')],
cmdclass=dict(build_ext=CMakeBuild),
zip_safe=False,
packages=setuptools.find_packages()
)
My CMakeLists.txt file has an install instruction that looks like this:
install(TARGETS packagebindings COMPONENT python LIBRARY DESTINATION ${Python_SITELIB})
To summarise, here are the files that are created when running pip install .:
path/to/site-packages/package/* - removed by pip uninstall package
path/to/site-packages/package-0.0.1.dist-info/* - removed by pip uninstall package
path/to/site-packages/packagebindings.cpython-37m-x86_64-linux-gnu.so - still present after pip uninstall package
I would like to know how make it so that running pip uninstall . removes the .so file.
If a further MRE is required, I can link to a repository.
Your CMake install target seems to place the .so directly into the python installation directory (DESTINATION ${Python_SITE_LIB}). I'm guessing this stops the .so from being registered by Python proper, so it is not removed when uninstalling. I would suggest to make CMake place the .so in a distribution directory, and then add the following option to setup():
data_files = [("installation_bin", ["distribution_bin/library.so"])]
This will let the .so be tracked by the Python package manager. The first string is a directory relative to the installation prefix. The second string is the .so file in your distribution, relative to the setup.py script.

How do I add all include .h files in python directory

I am trying to install PyHook using PIP. When I run the command on cmd pip install pyhook3 I get a C1080 error that tells me there is no such .h file located in my directory. I traced the directory, downloaded the file and it showed me another. I kept doing this until I noticed that there seems to be no end. There seems to be a lot of missing .h files in this includes folder C:\Users\User\AppData\Local\Programs\Python\Python38-32\include directory. I don't want to have to download or copy and paste source code for each of these files. Is there any way to get all of them at once, or am I missing the plot entirely?
pyhook is a Python package with binary dependencies.
When running pip install pyhook3 you download the source and ask your computer to build it so it can be installed. It thus requires a compiler and a set of header files that are apparently missing for you.
A workaround may be to download manually a compiled version of this package and install it.
You can find on this page a set of binary wheel for pyhook (not pyhook3) for python3 (32 or 64 bit). Once you have downloaded the correct .whl, you can install it with pip install the_filename_you_have_downloaded.whl

Installing GDAL Python binding in Ubuntu to use as standalone module

I am trying to export a GeoTiff with Blender using the Blender Python API (based on Python 3), so I've decided to install GDAL on Ubuntu (14.04). What I would like is to get the module as a standalone folder that I could put in the modules directory of Blender (/home/user/.config/blender/2.73/scripts/modules).
The thing is I've run through several different problems trying to install GDAL. I've tried to install from source (for GDAL 2.0.0) here : Official PyPi Gdal
I ran sudo apt-get install libgdal-dev gdal-bin (I list it here because it may be important)
When I am in the extracted GDAL folder, using python setup.py build & python setup.py install, the library installs to /usr/local/lib/python2.7/dist-packages/osgeo. However, when I run python from command line, running from osgeo import osr returns ImportError: No module named _gdal
Following GDAL via pip , I used pip (pip install GDAL) to install the library, and the folder it went to was /usr/lib/python3/dist-packages/osgeo (using pip show ...). Again, running python3 and trying to import results in the same error. Of course, when I copy-paste each folder in the blender module directory, I get the same error in the Blender Python console.
So I decided to compile the sources using ./configure --with-python & make & make install in the source folder. I then copied the folder GDAL-x.x.x/build/lib.linux-x86_64-3.4/osgeo to the blender modules directory and got this time the error when importing : ImportError: /home/yvesu/.config/blender/2.73/scripts/modules/osgeo/_gdal.so: undefined symbol: _Py_ZeroStruct.
Trying to compile with python3 using python3 setup.py build returns the error error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
EDIT 1:
I think I've found the solution : I went to the directory swig/python (not found in a GDAL-1.11.0 folder but gdal-1.11.0 fodler, can't remember where I downloaded it from), ran python3 setup.py build & python3 setup.py install and could finally find the folder in /usr/local/lib/python3.4/dist-packages/GDAL-1.11.0-py3.4-linux-x86_64.egg/osgeo. When I put this osgeo folder oni the Blender modules directory, I was able to import osgeo in Blender. I will report if anything went wrong.
I think I've listed all my attempts at installing GDAL on Ubuntu. Can anyone point me in the right direction? Do you think it is even possible to install it as a standalone module, or do I need linked libraries through LD_LIBRARY_PATH?
Here is the solution I've found :
Download Gdal sources (v2.0.0 is the current stable release) from ftp://ftp.remotesensing.org/gdal/2.0.0/ or http://download.osgeo.org/gdal/2.0.0/ and untar
Go to the directory gdal2.0.0/swig/python
Run python3 setup.py build & python3 setup.py install
Finally find the module folder in, on Ubuntu : /usr/local/lib/python3.4/dist-packages/GDAL-2.0.0-py3.4-linux-x86_64.egg/osgeo
I can now use it in Blender (copying in the modules directory)

Building Healpy library - can not find cfitsio library

I am trying to build a Python library Healpy. My first try was to use pip. After typing:
>pip install --user healpy
i got result:
>checking if library 'cfitsio' is installed
>error: No such file or directory
After that i tried to build library on my own - i downloded the sources and builded cfitsio using commands:
>/.configure
>make
>make install
after doing that i got a libcfitsio.a file, pkg-config folder with .pc file and some .h files in include folder. But after typing:
> python setup.py install
i got the same error. I got the same error after building lib in Windows. Did anyone have similar problem ? I would be very greateful for any suggestions.
As mentioned in the healpy INSTALL documentation you must specify the PKG_CONFIG_PATH environment variable if you want to use external cfitsio or healpix modules:
PKG_CONFIG_PATH=/path/to/local/lib/pkgconfig
Note: adapt with your own path obtain from the cfitsio compilation process!
Then you shall be able to run the compilation of healpy...

Installing a .tar.bz2 in windows

I am a newbie to installing python extensions working on Windows 7, running Python 2.6 - I need to install the Levenshtein library from
http://code.google.com/p/pylevenshtein/downloads/detail?name=python-Levenshtein-0.10.1.tar.bz2&can=2&q=
When I unzip the downloaded file, it gives me the following list of files:
COPYING
gendoc.sh
Levenshtein.c
Levenshtein.h
MANIFEST
NEWS
PKG-INFO
README
setup.cfg
setup.py
StringMatcher.py
How do I install the Levenshtein library so I could import and use it into my python code?
Assuming you have Python already installed on on you PATH, you can do this:
python setup.py install
However, it seems to have a compiled extension so you will probably also need a complete Windows development environment to install that (it is a source distribution). So if you don't it may not work. Your best bet would be to find that as an MSI package, if you can.
Here is quite a large section of the documentation easily found by doing some research.
http://docs.python.org/install/index.html
It appears that you will want to run:
python setup.py install --prefix="\Temp\Python"
to install modules to the \Temp\Python directory on the current drive.
Some more info:
If you don’t choose an installation directory—i.e., if you just run
setup.py install—then the install command installs to the standard
location for third-party Python modules.
The default installation directory on Windows was C:\Program Files\Python under Python 1.6a1, 1.5.2, and earlier.

Categories