how to install METIS library for python? - python

I want to install METIS for python on windows7.i use:
pip install metis
I got this result:
Requirement already satisfied: metis in
c:\users\mina\appdata\local\programs\python\python36\lib\site-packages
(0.2a4)
and I used the following code:
make config shared=1
I got this result:
make: *** No rule to make target `config'. Stop.
Maybe you can help me.

pip install metis
-or-
easy_install metis
You might need to add "shared=1" to your config options when building Metis from source so it builds a shared library instead of a static one.
Note that the shared library is needed, and isn’t enabled by default by the configuration process. Turn it on by issuing:
make config shared=1
make install
Then, set up your METIS_DLL environment variable:
export METIS_DLL=/usr/local/lib/libmetis.dylib
Source: https://metis.readthedocs.io/en/latest/

The metis-python is just a wrapper, it does not have the core METIS yet, you need to install METIS separately. You can get the source from here:
http://glaros.dtc.umn.edu/gkhome/metis/metis/download
the installation instruction can be found inside the package at Install.txt. Once you download and unpack it, Suraj M's answer above will come in handy.

One more thing to note that when I install python metis on Ubuntu 16.04 machine.
After you make install, you may only get libmetis.so in the /usr/local/lib directory.
Therefore
export METIS_DLL=/usr/local/lib/libmetis.dylib
should be changed to
export METIS_DLL=/usr/local/lib/libmetis.so

Related

Cannot install Python projects in readthedocs

I've got a couple of projects here for which I'm preparing documentation at the moment, hosted at readthedocs.org. FYI, all of them use poetry and I use custom .readthedocs.yml files with this entry:
python:
install:
- method: pip
path: .
It works fine for most projects, but it fails for two for different reasons during installation of the project via pip:
The first one uses PyGObject, which failes like this:
Package gobject-introspection-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gobject-introspection-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gobject-introspection-1.0' found
Command '('pkg-config', '--print-errors', '--exists', 'gobject-introspection-1.0 >= 1.56.0')' returned non-zero exit status 1.
Try installing it with: 'sudo apt install libgirepository1.0-dev'
So it seems that PyGObject cannot be installed without some system packages to be installed. I could rearrange the code so that the import is not top-level. But still I need it in the dependencies. Can I tell pip install to ignore this single package somehow? Any other idea?
The second project compiles some C++ code via Cython and fails, because it's missing a library. I use a custom build script in the pyproject.toml:
[tool.poetry.build]
script = "build.py"
generate-setup-file = false
Is there some flag in pip that I could set and retrieve in build.py to skip the compilation? Or is there a better way?

Can't find Brew installed packages on Mac M1 in Pycharm

I'm having trouble installing packages and using them in Pycharm. I've followed various threads (I'm new to Macs and seem to have tried everything) now I'm stuck.
In this case, I want to use the package xgboost.
I have brew installed, after launching a terminal using Rosetta:
%brew install xgboost
Warning: xgboost 1.3.3 is already installed and up-to-date.
It appears installed OK here:
/opt/homebrew/Cellar/xgboost
I also have Python installed here:
/opt/homebrew/Cellar/python#3.9
But no matter how I configure an Interpreter in Pycharm, I can't seem to get the package recognised.
Where have I gone wrong?
I am very unsure exactly how, but I've got this working.
Following: https://abbasegbeyemi.me/blog/homebrew-python-apple-m1
I changed the order of elements in my path:
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin
then a new interpreter in Pycharm using:
usr/local/Cellar/Python#3.9/3.9.2_2/bin/python3.9
Now I can install packages just using pip in pycharm and it works.
This has been 6 hours of pain - warning to anyone who isn't well versed in macs, setting up an M1 for python dev was a complete nightmare for me.
Docs: https://xgboost.readthedocs.io/en/latest/build.html
Pre-built binary wheel for Python
If you are planning to use Python, consider installing XGBoost from a pre-built binary wheel, available from Python Package Index (PyPI). You may download and install it by running
# Ensure that you are downloading one of the following:
# * xgboost-{version}-py2.py3-none-manylinux1_x86_64.whl
# * xgboost-{version}-py2.py3-none-win_amd64.whl
pip3 install xgboost

Pip install --global-option="-L/<library path>": option -L not recongnised

I am trying to install cartopy on a Windows machine, and have previously installed QGIS and GEOS through OSGeo4W64. Now, when I try installing cartopy, I get the following error:
fatal error: 'geos_c.h' file not found
As mentioned, GEOS does exist and the file is also to be found within the directory. I the tried giving Pip the absolute path to the library as a global option, as follows:
pip install --global-option="-Lc:\OSGeo4W64\include"
This, unfortunately didn't work because Pip didn't recognise the -L library option:
error: option -L not recognized.
I tried -I, -l, and -i as well, just to see what would happen, but I get the same error every time. I also found examples on how to give paths to global-option and they did use -L and -I without problems. What could I be doing wrong?
Any help would be greatly appreciated.
It depends where you get your GEOS from as to which GEOS header file you should be linking against. If you get it from Christoph Gohlke's excellent binaries, or conda-forge, enthought, or Anaconda, I believe all rename geos_c.h to geos.h. If you get it from other sources, it may be that that renaming doesn't take place.
You can see how conda-forge build cartopy on Windows at https://github.com/conda-forge/cartopy-feedstock/blob/master/recipe/. The two important files:
https://github.com/conda-forge/cartopy-feedstock/blob/master/recipe/bld.bat
https://github.com/conda-forge/cartopy-feedstock/blob/master/recipe/cartopy.win.patch
Notice how that latter patch file renames the header dependency to geos.h, rather than geos_c.h because it is using the GEOS packaged by conda-forge. You may need to do a similar thing in your situation.
A history on this subject can also be found at https://github.com/SciTools/conda-recipes-scitools/issues/29#issuecomment-66497972.

"Could not find protoc command. Make sure protobuf is installed and your PATH environment is set"

I am trying install imposm.parser library on python.
After I typed - pip install imposm.parser, it said it could not find protoc command.
but I have already got protobuf 2.6.1 library installed on python!? I don't understand.
Thanks
Andrew
You need to download Protocol Compiler separately from Protocol Buffers library. Get it from Google Developers Protocol Buffers Download page.
Most executables of python installed using pip (or easy install) are stored in the Scripts-subfolder of Python. In my case, this is C:\Python27\Scripts.
You should check, if your PATH-Environment containts that directory. Further information are already on this SO-question.

Homebrew failing to install postgresql; python 64-bit errors

I'm getting errors when running
$ brew install postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.bz2
File already downloaded in /Users/neil/Library/Caches/Homebrew
Warning: Detected a framework Python that does not have 64-bit support in:
/Library/Frameworks/Python.framework/Versions/Current/Python
e configure script seems to prefer this version of Python over any others,
you may experience linker problems as described in:
http://osdir.com/ml/pgsql-general/2009-09/msg00160.html
fix this issue, you may need to either delete the version of Python
own above, or move it out of the way before brewing PostgreSQL.
te that a framework Python in /Library/Frameworks/Python.framework is
e "MacPython" version, and not the system-provided version which is in:
/System/Library/Frameworks/Python.framework
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --datadir=/usr/local/Cellar/postgresql/9.1.2/shar
^C
Here's where python is located.
$ which python
/usr/local/bin/python
I modified my ~/.zshrc PATH from
export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
to
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
And although I'm getting python 64-bit errors, my version of python is 64-bit according to this SO post:
$ python -c 'import struct;print( 8 * struct.calcsize("P"))'
64
The problem pointed out in the referenced mailing list post is that the configure step isn't impacted by the PATH here. There's a whole other mechanism used to find things to link against; see Where do I set DYLD_LIBRARY_PATH on Mac OS X for a quick intro. You could try the suggested workaround given by the brew script--rename /Library/Frameworks/Python.framework/Versions/Current/Python to something else to get it out of the linker's search path, repeat the brew install, then put it back.
If you don't need Python bindings in your PostgreSQL, you can also just install it without Python bindings using brew install postgresql --no-python.
This command is installing the server, not the python bindings. Is that what you want? There is a installer for osx that will install the server for you.
Once you have done that, you can install the psycopg2 bindings directly from source.

Categories