Gurobipy DLL load failed - python-2.7

When trying to import gurobipy i get the following ImportError:
D:\Development\Anaconda3\envs\hiwi\python.exe D:/Development/Hiwi/Project_Code_Source/experiment/demo/run.py
Traceback (most recent call last):
File "D:/Development/Hiwi/Project_Code_Source/experiment/demo/run.py", line 2, in <module>
import experiment.demo.scenarios as scenarios
File "D:\Development\Hiwi\Project_Code_Source\experiment\demo\scenarios.py", line 15, in <module>
import framework.simu.ins_gen_v3 as insgen
File "D:\Development\Hiwi\Project_Code_Source\framework\simu\ins_gen_v3.py", line 10, in <module>
from gurobipy import *
File "D:\Development\Anaconda3\envs\hiwi\lib\site-packages\gurobipy\__init__.py", line 1, in <module>
from .gurobipy import *
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden. (English: Module not found.)
Process finished with exit code 1
Since searching google resulted in errors related to environment variables and 64 vs 32 bit Versions i checkt those.
I am running the 64 bit Versions of Annaconda (3.6 using a 2.7 env) on Windows 10 and Gurobi
Gurobi is installed according to this instruction (including the license): http://www.gurobi.com/downloads/get-anaconda
The GUROBI_HOME variable is correctly set to C:\gurobi702\win64 and the Path variable to C:\gurobi702\win64\bin
Python Path variables are set.
Following packages are installed: gurobi 7.5.1, mkl 2017.0.3, numpy 1.13.1, pip 9.0.1, python 2.7.13, setuptools 27.2.0, vs2008_runtime 9.00.30729.5054, wheel 0.29.0, wsgiref 0.1.2
Starting the gurobi console via cmd gurobi works fine.
I reinstalled my complete python environment multiple times and tried restarting after installation.

I got it running with a new conda environment and installing via python setup.py install, as mentioned by Greg Glockner and sascha.

This problem [from .gurobipy import] is caused from the IDE Pycharm on Ubuntu. I am not sure if you may face it with the other IDEs .
First You can make sure from the shell the python has gurobipy installed.
after you installed from the file Gurobi ~\gurobi752\win64
python setup.py install
then just run python from the shell as normal python command
python yourFileName.py and gurobi will works perfectly
In windows 10 i added the path of gurobi to the IDE pycharm
after python setup.py install and pip tool for gurobipy https://sites.google.com/site/pydatalog/python/pip-for-windows, then i added the path
Settings->Project Interpreter-> show all -> interpreter paths -> add your gurobi path
I hope it works cheers ;)

Related

ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

Possible duplicate of this question.
I have a gpu account to whom I connect through putty (ssh login). I have created a virtualenv there and I am installing tenorflow through pip for gpu. Everything works fine, when I run command
$ pip list
following list is being shown:
backports.weakref (1.0rc1)
bleach (1.5.0)
funcsigs (1.0.2)
html5lib (0.9999999)
Markdown (2.6.8)
mock (2.0.0)
numpy (1.13.1)
olefile (0.44)
pbr (3.1.1)
Pillow (4.2.1)
pip (9.0.1)
protobuf (3.3.0)
setuptools (36.0.1)
six (1.10.0)
tensorflow-gpu (1.2.1)
Werkzeug (0.12.2)
wheel (0.29.0)
But when I run:
$ python
>>> import tensorflow
It shows the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
<module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in
swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname,
description)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such
file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I have also set my environment variables like this:
export CUDA_HOME=/opt/cuda
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64"
Moreover, I found that libcusolver.so.8.0 is not there, while libcusolver.so.7.5
is there in cuda/lib64/.
Somehow tensorflow is finding wrong file or I ain't know nothing.
Any help would be appreciated as I am new to all this stuff.
Python version: 2.7
OS: Linux
This may be connected to the incorrect linking of your libraries.
Simply run sudo ldconfig /usr/local/cuda/lib64. It solved for me.
If you need to know more: ldconfig man page.
I solved the issue. Actually I have cuda 7.5 installed and I was installing latest tensorflow version which probably support cuda 8.0.
So I downgraded.
pip install --upgrade \ https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
If you installed tensorflow-gpu by using pip with prebuilt .whl, the cuda version were fixed. As far as I know, starting 0.11.0rc1, all the prebuilt packages are now built for cuda 8. So there are two ways to solve the problem:
install cuda 8 for the prebuilt packages tensorflow-gpu >= 0.11.orc1
keep cuda 7.5 stay, then build tensorflow-gpu from source code
If you are using cuda-9.0 try sudo apt install nvidia-cuda-dev (if you are using an Ubuntu distribution)

Python 2.6 'import site' failed error with 2.7 installed

I have Python 2.7 operating correctly on Windows. I installed 2.6 in another folder. However, when I run 2.6 in IDLE or PowerShell, it does not recognize basic commands and cannot import installed libraries. Whenever I launch 2.6, the first thing that comes up is:
'import site' failed; use -v for traceback
I can't find anything on this error aside from some mentions with specific libraries. Trying again using -v suggests 2.6 is pulling libraries from 2.7 which is causing some of the errors.
It then launches, but doesn't recognize installed libraries. For example:
import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
Similarly, simple commands like quit() or help result in:
Traceback (most recent call last): File "", line 1, in
NameError: name 'help' is not defined
I have tried reinstalling 2.6 and double-checked the registries are pointing to the right places. Virtualenv can't seem to run it either, so I'd like a solution that doesn't involve it...for now.
EDIT:
Running 2.6 with -v starts off like this:
PS C:\python26> python26 -v
installing zipimport hook
import zipimport # builtin
installed zipimport hook
C:\Python27\Lib\site.pyc matches >C:\Python27\Lib\site.py
import site # precompiled from >C:\Python27\Lib\site.pyc
For some reason, zipimport is pulling from 2.7, not 2.6.
I found a text_zipimport.py file, but it's beyond me.
Took a while, but I did solve this. When I installed 2.6, it did not add anything to the environment path. I'm working in windows, so here's what I did:
Start -> search for "environment"
Select "Edit environment variables for your account"
Click the variable Path and click Edit
Add "C:\Python26;C:\Python26\Scripts;" to the path
Ok
After that it loads properly.

PyMC installation error with pip

I am attempting to install PyMC using pip install pymc. I believe this command should install PyMC 2.3.6.
PyMC has a few dependencies, which I have in my PATH. I am running OSX 10.11.2 and my PATH includes Python 2.7.13, NumPy 1.12.0, Matplotlib 2.0.0, gcc, and gfortran.
Python (including pip) was installed using Homebrew. NumPy and Matplotlib were installed using pip. The gfortran compiler was downloaded and installed from the GCC Wiki for the purpose of this installation.
Executing pip install pymc yielded lots of output including the following lines.
Collecting pymc
Using cached pymc-2.3.6.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
running build_src
build_src
building extension "pymc.flib" sources
f2py options: ['skip:ppnd7']
f2py:> build/src.macosx-10.11-x86_64-2.7/pymc/flibmodule.c
creating build
creating build/src.macosx-10.11-x86_64-2.7
creating build/src.macosx-10.11-x86_64-2.7/pymc
IOError: [Errno 2] No such file or directory: 'skip:ppnd7'. Skipping file "skip:ppnd7".
updatevars:gradlike: attempt to change 'dimension(nx)' to 'dimension(na)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension(nx)' to 'dimension(nb)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension (nmu)' to 'dimension(nmu)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension (na)' to 'dimension(na)'. Ignoring.
rmbadname1: Replacing "index" with "index_bn".
Reading fortran codes...
Reading file 'pymc/flib.f' (format:fix,strict)
Line #34 in pymc/flib.f:" PARAMETER (infinity = 1.7976931348623157d308)"
get_parameters: got "unexpected EOF while parsing (<string>, line 0)" on ''
...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/2f/cr97n5v93mn04c3qbqd7r3q40000gn/T/pip-build-6Zmgcz/pymc/setup.py", line 124, in <module>
**(config_dict))
File "/usr/local/lib/python2.7/site-packages/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
...
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/2f/cr97n5v93mn04c3qbqd7r3q40000gn/T/pip-build-6Zmgcz/pymc/
As suggested in these two pip installation threads about egg_info errors [1, 2], I ran pip install —upgrade setuptools and pip install ez_setup. Once these items were installed I ran into the same types of errors pasted above.
As noted in other package installation threads, I am willing to use conda to install PyMC if I cannot resolve these issues. However, I'd like to investigate this installation issue first.
Would anyone happen to know what my issue is here? Might there be some steps I can take to successfully install PyMC using pip?
I had the same problem. I don't understand the root cause, but I fixed it by downgrading numpy to version 1.10.1: pip install numpy==1.10.1
I also met this problem while trying to install pymc from pip or source code, but I found a solution that might be useful.
The reason that causes the problem might be the file setup.py, in which the script check the compile env. I didn't read the code very carefully, but in the function build_ext() I think the codes first check whether some compile environments have already been installed into OS. If installed, the script will use them as defaults; if not, use ones in somewhere else (the comment says 'from netlib sources').
I infer the problem is caused by the compile environments that have already been installed in the OS, so I modify the file setup.py to skip this part of codes, and let the script use the netlib source. Then I run sudo python setup.py install. There are some error and warning messages, but the folder 'pymc' emerges in python library, and some simple test codes run successfully.

Error importing theano "cannot import name gof"

I am current getting the error
ImportError: cannot import name gof
when importing theano.
>>> import theano
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import theano
File "C:\Python27\lib\site-packages\theano\__init__.py", line 63, in <module>
from theano.compile import (
File "C:\Python27\lib\site-packages\theano\compile\__init__.py", line 9, in <module>
from theano.compile.function_module import *
File "C:\Python27\lib\site-packages\theano\compile\function_module.py", line 16, in <module>
from theano import gof
ImportError: cannot import name gof
I am using python 2.7.10 (). Theano is installed using pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git.
Hope to get you suggestion to solve this problem
Most of the time, when I see this error, it is caused by those 2 errors:
1) A syntax error in Theano. Update Theano and make sure to have no local modifcation. I nerver saw this error in the master of Theano, but just in case.
2) When there is multiple version of Theano that are installed.
In both case, remove all version of Theano. Do it multiple time to be sure there is none left. Then install again.
From memory, this always solved the problem when it wasn't a syntax error during development (but not in the master version of Theano that you use)
This ImportError can be caused because Theano is unable to compile the gof module itself. If this is the case, you will see an error message that looks like "Exception: Compilation Failed (return status=1): C:\Long\Path\...\mod.cpp:1: sorry, unimplemented: 64-bit mode not compiled in".
Fixing With Conda
If you are installing theano into a conda environment, make sure that you have a C compiler available to that environment.
The command
conda install m2w64-toolchain
will provide a C compiler to your environment that's isolated from the rest of the machine.
After the m2w64-toolchain package is installed, import theano should work
Fixing Manually
If you are installing Theano yourself, two points from these threads may help:
Install the bleeding edge version of Theano
Install libpython from http://www.lfd.uci.edu/%7Egohlke/pythonlibs/
I assume you're using Windows 7 or later.
If you have installed Python Anaconda, then open Windows Powershell or Command Prompt and type conda install mingw libpython before typing pip install theano
Alternatively, if you don't have Anaconda, download those packages from
anaconda.org/anaconda/mingw/files
anaconda.org/anaconda/libpython/files
github.com/Theano/Theano
Then open Command Prompt, navigate to each folder and type python setup.py install
Now run Python and import theano
Possible errors:
If you get the RuntimeError: "To use MKL 2018 with Theano you MUST set "MKL_THREADING_LAYER=GNU" in your environement" then
Go to Control Panel > System > Advanced system settings and select "Environment Variables".
In the "System variables" section, make a new variable name MKL_THREADING_LAYER and set its value to GPU
If you get other kinds of errors, then try the following:
Make an empty file called .theanorc (a file extension without a file name) in your home folder C:\Users\<username>. If you get the error "You must type a file name" then see stackoverflow.com/q/5004633
Open .theanorc and write this:
[global]
cxx=C:\<path to Anaconda>\Anaconda3\MinGW\bin\g++.exe
Run Python again and import theano. If it works, then you can probably delete .theanorc
In my case, the fix was to install a python build that's callable as a shared library:
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 2.7.15

Upgrade to Python 2.7.10: Target WSGI script cannot be loaded as Python module

When I upgrade Python from 2.7.9 to 2.7.10 with anaconda, I get the following error in my apache2 log and my websites don't work any more.
mod_wsgi (pid=608): Target WSGI script '/www/wsgi_scripts/django_myproject.wsgi' cannot be loaded as Python module.
Exception occurred processing WSGI script '/www/wsgi_scripts/django_myproject.wsgi'.
Traceback (most recent call last):
File "/www/wsgi_scripts/django_myproject.wsgi", line 8, in <module>
import django.core.handlers.wsgi
File "/Users/xnx/anaconda/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 6, in <module>
from io import BytesIO
File "/Users/xnx/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/xnx/anaconda/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/xnx/anaconda/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
I expect this is some kind of mismatch in package library versions, but does anyone know which one?
Double check your PYTHONPATH if it's correct (you don't override it anywhere in your startup files).
Otherwise you may consider downgrading your Python from 2.7.10 to 2.7.9.
For example (as suggested in here):
conda install python=2.7.9
or when using Homebrew try:
brew switch python 2.7.9
as it could be some particular problem with 2.7.10.
Alternatively use Python 3.x instead.
My suspicion is that this is a problem with Anaconda as I've just hit the same problem. I've reported an issue here: https://github.com/conda/conda/issues/1367
update:
The conda guys have now released a fixed virtualenv package that no longer has this problem.