How to install pyscipopt and its dependency - python

I am trying to install pyscipopt. This should be done using pip install pyscipopt. The only catch is that pyscipopt requires the SCIP Optimization suite. Here is where I am having trouble. I wanted to make sure that my basic steps were correct.
The first way:
Following (https://github.com/SCIP-Interfaces/PySCIPOpt/blob/master/INSTALL.md)
Download SCIP optimization suite from https://www.scipopt.org/index.php#download
Then cd to my downloads folder. There, there is
scipoptsuite-7.0.1.tar
Run
tar xvfz scipoptsuite-7.0.1.tar
cd scipoptsuite-7.0.1
Then, following (https://scipopt.org/doc/html/CMAKE.php)
mkdir build
cd build
cmake ..
make
make check
make install
Alternatively, I also tried using make (https://scipopt.org/doc/html/MAKE.php)
I then either set export SCIPOPTDIR=<path_to_install_dir>, where <path_to_install_dir> is the path to scipoptsuite-7.0.1, in my downloads directory, or I added the scipoptsuite-7.0.1 directory to my $PATH. Either way, pip install pyscipopt worked.
However,
Ultimately I get (on one machine)
>>> import pyscipopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/usr/anaconda/lib/python2.7/site-packages/pyscipopt/__init__.py", line 10, in <module>
from pyscipopt.scip import Model
ImportError: dlopen(/Users/usr/anaconda/lib/python2.7/site-packages/pyscipopt/scip.so, 2): Library not loaded: libscip.7.0.dylib
Referenced from: /Users/usr/anaconda/lib/python2.7/site-packages/pyscipopt/scip.so
Reason: image not found
On another machine I get
>>> import pyscipopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/s/Library/Python/2.7/lib/python/site-packages/pyscipopt/__init__.py", line 10, in <module>
from pyscipopt.scip import Model
ImportError: dlopen(/Users/sam/Library/Python/2.7/lib/python/site-packages/pyscipopt/scip.so, 2): Library not loaded: libscip.7.0.dylib
Referenced from: /Users/s/Library/Python/2.7/lib/python/site-packages/pyscipopt/scip.so
Reason: unsafe use of relative rpath libscip.7.0.dylib in /Users/s/Library/Python/2.7/lib/python/site-packages/pyscipopt/scip.so with restricted binary
Is anyone able to install this software on a mac and give me a step by step guide, so at least I know I am not making any obvious mistakes? I guess there may be problems with my computers that can not be resolved, but I wanted to just make sure I had pieced together the instructions from various links correctly..
Another things I tried was just downloading the sh and running
sh scipopsuite-[VERSION].sh. This is considerably faster than make/cmake, and gives me what seems to be required in terms of lib, include and headers, but then when I try to pip install pyscipopt I usually get errors of the form scip/scip.h no such file or directory, command gcc failed as in (https://github.com/SCIP-Interfaces/PySCIPOpt/issues/54).

Related

Error when running install and import from Github

I am using python; colab.
I tried to install package from" github.com/jleinonen/keras-fid" to import fid. And first time I used:
!pip install git+git://github.com/jleinonen/keras-fid.git
but I got error;
Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
So I used: !git clone
I install package from Github by using
!git clone https://github.com/jleinonen/keras-fid.git
than try to import module
However, I'm not sure but I think because package name contains "-", I got
SyntaxError: invalid syntax
How can I import the module from this package
The - is a red herring. The problem is that the Github repo cannot be pip installed because it does not contain a setup.py.
When you git cloned the code, you simply copied it to your environment. It's still not trivially installable ... though what you can do now is either add the cloned directory to your PYTHONPATH, or copy the file fid.py from inside it to somewhere which is already on your PYTHONPATH.
Quick demo:
bash$ python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fid'
bash$ git clone https://github.com/jleinonen/keras-fid.git
Cloning into 'keras-fid'...
remote: Enumerating objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (12/12), done.
Now, we have a local clone, but as you can see, it is not yet installed:
bash$ python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fid'
You can add the directory name (which does contain a hyphen, but that's unproblematic here) to your PYTHONPATH, and then it works ... except the code contains a syntax error.
bash$ PYTHONPATH=${PYTHONPATH+$PYTHONPATH:}`pwd`/keras-fid python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/keras-fid/fid.py", line 134
def __init__(self, generator, image_range=,
^
I have no idea what the code is supposed to do, and I know nothing about Keras or Google Colab; but changing it to image_range, without an equals sign before the comma at least lets me bypass this error.
how to add the path to PYTHONPATH in google colab seems to have tips for how to do something similar inside Google Colab.

how to customise files being copied into tmp directory when running a local pip install?

I'm trying to pip install the python binding of MXNet library from source code:
https://mxnet.incubator.apache.org/install/ubuntu_setup.html#install-mxnet-for-python
After the main binary is built successfully using g++, there is no problem in installing its python binding in dev/editable mode:
pip install -e .
however when I try to deploy the full package (instead of just creating a symbolic link)
pip install .
I encounter the following error:
Processing ~/git-fork/mxnet/python
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-k3hfc693/setup.py", line 47, in <module>
LIB_PATH = libinfo['find_lib_path']()
File "/tmp/pip-req-build-k3hfc693/mxnet/libinfo.py", line 74, in find_lib_path
'List of candidates:\n' + str('\n'.join(dll_path)))
RuntimeError: Cannot find the MXNet library.
List of candidates:
/tmp/pip-req-build-k3hfc693/mxnet/libmxnet.so
/tmp/pip-req-build-k3hfc693/mxnet/../../lib/libmxnet.so
/tmp/pip-req-build-k3hfc693/mxnet/../../build/libmxnet.so
../../../libmxnet.so
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-k3hfc693/
It appears that pip didn't copy ../../lib/libmxnet.so into tmp since it is outside the python package directory. What should I do to instruct pip to copy that file (and if possible, everything under parent directory) when installing?
Where is your libmxnet.so located? It should be in the main-directory, so in your case: /git-fork/mxnet. Then the setup.py script should work out of the box. You could also manually set the path in setup.py, by adjusting the following line LIB_PATH = libinfo'find_lib_path'

Error while trying to port a repo from github

There is a github code I am trying to use that is located here.
I am trying to run params.py which is a code that will take a binary file and converts it so that I can plot it (or so I think).
I tried to run:
pip install git+https://github.com/PX4/pyulog.git
However, that gave me an error:
C:\Users\Mike\Documents>pip install git+https://github.com/PX4/pyulog.git
Collecting git+https://github.com/PX4/pyulog.git
Cloning https://github.com/PX4/pyulog.git to c:\users\mike\appdata\local\temp\pip-t_vvh_b0-build
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Anaconda3\lib\tokenize.py", line 454, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Mike\\AppData\\Local\\Temp\\pip-t_vvh_b0-build\\setup.py'
Pip install tries to install the module from :
PyPI (and other indexes) using requirement specifiers.
VCS project urls.
Local project directories.
Local or remote source archives.
When looking at the items to be installed, pip checks what type of item each is, in the following order:
Project or archive URL.
local directory (which must contain a setup.py, or pip will report an error).
Local file (a sdist or wheel format archive, following the naming conventions for those formats).
A requirement, as specified in PEP 440.
In your case, git repo doesn't meet the requirement. It doesn't have setup.py that's why you get the error.
Instead try cloning the repo on your local machine.

DLL load failed: The specified module could not be found for pygpu/libgpuarray

I'm using libgpuarray (openCL) but can't seem to get the GPU working with Theano in anaconda 2. When I try to run the test I get:
ERROR (theano.gpuarray): pygpu was configured but could not be
imported Traceback (most recent call last): File
"C:\Users\username\Anaconda2\lib\site-packages\theano-0.9.0.dev1-py2.7.egg\theano\gpuarray__init__.py",
line 21, in import pygpu File
"C:\Users\username\Anaconda2\lib\site-packages\pygpu-0.2.1-py2.7-win-amd64.egg\pygpu__init__.py",
line 7, in from . import gpuarray, elemwise, reduction ImportError:
DLL load failed: The specified module could not be found.
Theano works fine with the cpu. I followed this documentation. I ran the command code "python setup.py build" and "python setup.py install" on setup.py in the libgpuarray folder (after I used cmake to install libgpuarray) to get pygpu and it ran successfully. After running cmake I get the gpuarray.dll file yet this error still occurs. Do I need to do something with it or is there something else happening?
I solved this problem by copying gpuarray.dll generated in your build dir into C:\Windows\System32.

Python installation error: NumPy package

I am trying to follow this tutorial and getting an error when I do the following:
(DataVizProject) $ pip install -r requirements.txt
It gives me a big error log, the last few lines of which are :
C:\python\new-coder\dataviz\DataVizProj\build\numpy\numpy\distutils\system_info.
py:1422: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
warnings.warn(LapackSrcNotFoundError.__doc__)
error: Unable to find vcvarsall.bat
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in C:\python\new-coder
\dataviz\DataVizProj\build\numpy
I know it doesn't work because when I do the following steps:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>>
Thanks a lot!
#Hasnain, when you are using python in windows, eventually you will see this error for some packages.
You have three options when it happen (in order of relevance):
1 - Try to download a MSI file. It will install the library without any problems. To numpy specifically you can download here (http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy)
2 - You can download the whole file and try a python setup.py install and modify the packacge if it raise some errors.
3 - You can compile your own library for your operational system.
Many MSI files you can find here (http://www.lfd.uci.edu/~gohlke/pythonlibs/)
The method recommended in that tutorial works well for Unix systems. If you are on Windows you will go through a lot of trouble trying to build numpy from sources with pip. I will save you some time, follow the official recomendation and try some binary install of the recommended ones in the official Scipy website. I personally recommend you the Anaconda or the Enthought distribution.
Usually when installing packages on windows, by default python searches for Visual Studio 2008 . You can either install it or use MinGW Compiler.
If you decide to use MinGW you should edit your distutils.cfg file in Python27\Lib\distutils directory :
[build]
compiler = mingw32
[build_ext]
compiler = mingw32

Categories