qhull library is not loaded in python - python-2.7

I recently installed a package that only runs with python2.7. Within this package, qhull is imported by
import matplotlib._qhull as _qhull
which leads to getting this error
ImportError:dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_qhull.so, 2): Library not loaded: /opt/local/lib/libqhull.8.0.dylib
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_qhull.so
Reason: image not found
I have reinstalled qhull by brew, but I still get the above error. I have checked /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/ and _qhull.so* was there.
I have checked brew doctor and didn't get any complaint regarding qhull. Library qhull can be found in /opt/local/lib/ on my system. I also run
python2.7 -m pip install --upgrade matplotlib
to make sure that my matplotlib is upgraded.
As I mainly work with Python3, I would look for a solution that does not cause any changes to my python3 configuration. Do you have any suggestions on solving this problem?

Related

Error loading psycopg2 module: Library not loaded: libpq.5.dylib

I am trying to run a Django project with Postgres database. I use Postgres 13.4 installed via postgressapp (UNIVERSAL with all currently supported versions) and python 3.9 (in venv). I work on Mac with Apple M1 chip, macOS Big Sur.
I faced the following well-known problem:
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/mymac/PyCharmProjects/projectname/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 2): Library not loaded: /opt/homebrew/opt/postgresql/lib/libpq.5.dylib
  Referenced from: /Users/mymac/PyCharmProjects/projectname/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so
  Reason: image not found
With searching, I found some discussions like this: https://github.com/psycopg/psycopg2/issues/1216. It seems that the most relevant solution is "RyanDurk commented on Jan 27":
$ brew install libpq --build-from-source
$ export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
$ pip install psycopg2
Unfortunately, in my case it does not help.
Then, I found some recommendations here: Library not loaded: /usr/local/lib/libpq.5.4.dylib and tried them. In particular, I tried to reach libpq.5.dylib via symlink like:
ln -s  /Library/PostgreSQL/13/lib/libpq.5.dylib /opt/homebrew/opt/postgresql/lib/libpq.5.dylib (the solution marked as accepted by topic starter), but also unsuccessfully.
I tried to install postgres from postgresql.org, then uninstall/reinstall postgres with homebrew, then
gem uninstall pg -> bundle install
with the same result.
I have run the same project successfully before, on the mac with Intel chip and PyCharm community edition. Also the same project runs normally on Linux.
If you have any idea what happens and how to fix this problem, please help me. I provide more details if necessary.
I had the same error after brew decided to upgrade my postgresql package to version 14 (your version may vary).
There was this part of the error message:
Library not loaded: '/usr/local/opt/postgresql/lib/libpq.5.dylib'
...
Reason: tried: '/usr/local/opt/postgresql/lib/libpq.5.dylib' (no such file)
I basically found the new location of the libpq and symlinked it to the location where psycopg2 was looking for it:
ln -s /usr/local/lib/postgresql#14/libpq.5.14.dylib /usr/local/opt/postgresql/lib/libpq.5.dylib
Hope that helps anyone else with a similar issue.

Statsmodels Installation Error

Whenever I tried to install "Statsmodels" using pip or easy_install the following error is showing.
enter image description here
I have tried to install scipy individually, same thing happens. What to do?
Installing statsmodels is quite easy, when numpy and scipy is available.
Installing scipy (using pip or easy_install = from sources by default) on the other hand is a nightmare on Windows, as it needs a C-Compiler, Fortran-Compiler and for example BLAS which is the error shown in your case.
The official docs of scipy do not recommend this manual install on Windows.
A few years ago there were official prebuilt binaries, but that's not the case anymore.
A few sources of prebuilt binares are given in the docs above and i highly recommend anaconda.

How to install GDAL/scipy using cmd in window?

I downloaded scipy-0.17.0-cp27-none-win_amd64.whl and GDAL-1.11.4-cp27-none-win_amd64.whl from gohlke in C:\Python27\Scripts
To install I used
pip install scipy-0.17.0-cp27-none-win_amd64.whl
pip install GDAL-1.11.4-cp27-none-win_amd64.whl
It says the installation is complete but when I import the libraries as
import scipy
import gdal
it shows error as
No module named gdal
No module named gdal
However, I installed the matplotlib, numpy in the very same way and they are working absolutely fine.
I solved this problem eventually to found the mistake in my approach.
This problem can occur with anyone using ArcGIS in one's system.
ArcGIS comes with it's default Python package and if one installs python separately, each time the new libraries gets installed in the newer Python installation not in ArcGIS.
Therefore, the pyhton IDLE which one uses need to be from another Python installation.
Here in my case, ArcGIS has Python 2.6 and I have made an separate installation using Python 2.7.11.
All the libraries were getting installed in right place but I was opening the wrong IDLE to write scripts hence getting error.

not able to upgrade matplotlib to 1.4.3 on ubuntu 14.04

I've tried upgrading matplotlib using the following commands:
$export PYTHONHOME=/usr/lib/python2.7/
$sudo easy_install -U distribute
$sudo pip install --upgrade matplotlib
But none of them have worked. It shows an error after the matplotlib 1.4.3 package is downloaded but not installed.
Can anyone help upgrading this correctly?
The error you get says this.
============================================================================
* The following required packages can not be built:
* freetype, png
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Storing debug log for failure in /home/snapey/.pip/pip.log
If you look further up, it says
REQUIRED DEPENDENCIES AND EXTENSIONS:
... <Some other packages, all present>
freetype: no [The C/C++ header for freetype2 (ft2build.h)
could not be found. You may need to install the
development package.]
png: no [pkg-config information for 'libpng' could not
be found.]
So, it's telling you the problem - freetype and png are not present and cannot be built
To rectify this - install them like so:
sudo apt-get install libfreetype6-dev libpng12-dev
This is almost a duplicate question, but looks like the problem is Python 3 specific (it isn't).
I found I then had to run pip install --upgrade matplotlib twice, as it failed with an error about python.h first time, but then I had matplotlib 1.4.3. Tested on Ubuntu 14.04 64 bit, python 2.7
As an aside - this is really ugly and should probably be raised with Ubuntu and / or matplotlib devs.

ImportError when importing certain modules from SciPY

I have used Scipy for some time. This is the first time I am using it for Signal processing!
But when I import modules like
from scipy import signal
from scipy import special
I get the error:
ImportError: DLL load failed: The specified module could not be found.
I am using Python 2.7.3 with Scipy 0.12.0 on 32-Bit Windows.
What should I do ?
This problem can be solved if instead of installing the usual numpy distribution, the numpy-MKL package is installed.
This package is available here.
Do remove the previous installation before going with the new one!
I already had numpy+mkl installed, but still I faced similar error.
Reinstalling has solved the issue:
pip uninstall numpy-1.13.1+mkl-cp35-cp35m-win_amd64.whl
pip install numpy-1.13.1+mkl-cp35-cp35m-win_amd64.whl
I installed numpy-MKL from here for Python 3.5.1, but it didn't solve the problem until I added the folder C:\Program Files\Python35\Lib\site-packages\numpy\core to system path.
Similar to the OP, I already had the Intel MKL libraries installed on my system. I was unable to load scipy.linalg with the same error message. I uninstalled the old version of numpy and scipy (which I installed before installing the Intel compilers and math libraries). Then ran pip install scipy, and magically I could now import scipy.linalg without the error.
I'm not entirely sure what caused it, and why it was unable to find the library it needed. But it somehow fixed the problem for me on Python 3.7.1 with Anaconda.
I had an issue importing sklearn because of my Scipy installation.
I fixed this by going to here and downloading the right version of numpy for my computer. Then I did the same for Scipy by going here and downloading the MKL version for my computer.
Once I did that, everything worked!
To check the supported tags for wheel version for your system you can run the following command in the command prompt: pip debug --verbose.
You can install the .whl files for numpy and scipy by doing: pip install {filename}.whl
I had this issue on 3.6 and reinstalling didn't work,downloading the wheel didn't work. I found a solution that did work:
go to "site-packages/scipy" folder and open __init__.py file for editting.
At the very bottom add this line of code:
from . import signal
from . import special
from . import linalg
from . import <insert missing submodule here>
this is the only solution that has worked for me and it should work for any one