Error installing mpi4py - python

I'm trying to install mpi4py and have followed the installation instructions using pip found here: http://mpi4py.scipy.org/docs/usrman/install.html#using-pip-or-easy-install
I'm running a virtualenv with python 2.7.10 on Mac OS 10.11.6, and have installed mpich3 using homebrew.
This is the error when I attempt to run a test:
Lorens-MBP:mpi4py-mpi4py-b9fccf29258a lorensheets$ ../bin/python test/runtests.py
Traceback (most recent call last):
File "test/runtests.py", line 257, in <module>
sys.exit(main())
File "test/runtests.py", line 244, in main
package = import_package(options, pkgname)
File "test/runtests.py", line 109, in import_package
import mpi4py.MPI
ImportError: dlopen(/Users/lorensheets/Desktop/fresh/virtual/lib/python2.7/site-packages/mpi4py/MPI.so, 2): Library not loaded: /
Users/lorensheets/opt/usr/local/lib/libmpi.20.dylib
Referenced from: /Users/lorensheets/Desktop/fresh/virtual/lib/python2.7/site-packages/mpi4py/MPI.so
Reason: image not found

Try installing openmpi instead of mpich3

Related

Python Installation in local directory gives "ModuleNotFoundError": 'msvcrt'

I'm using my company's VM which already has Python 2.7 (comes with the OS) and Python 3.6.13 (Installed by the company)
Recently, there is a need to upgrade an application to latest version of Python ie: 3.10.2
So, I installed Python 3.10.2 in a local directory inside my $HOME. I referred to this link for the installation link.
While 2.7 & 3.6 are already there in the system.
Now, when I try to create a VENV with this python version (3.10.2), I see this error:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 69, in <module>
import msvcrt
ModuleNotFoundError: No module named 'msvcrt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/venv/__init__.py", line 10, in <module>
import subprocess
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 74, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
I found some solutions like this one: link but I cannot figure out how it will translate in my case since my installation directory is not /usr/local/... It is $HOME/path/to/dir
Python on Linux does not have the msvcrt module at all. It's strictly Windows only. You seem to have miscompiled your Python somehow, since it also doesn't have the _posixsubprocess module (and msvcrt is used for Windows detection in subprocess.py).
May I recommend using pyenv or asdf for custom Python versions? They're less likely to miscompile Python.

Not able to import camelot in Python 3.7(Anaconda) in MacOS Catalina

My environment specs
python --version
Python 3.7.6
anaconda --version
anaconda Command line client (version 1.7.2)
sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.2
BuildVersion: 19C57
I installed camelot from conda-forge
using the command below.
conda install -c conda-forge camelot-py
Attaching the logs when I try to import camelot for pdf parsing and text extraction purposes.
Traceback (most recent call last):
File "/~/PycharmProjects/Utilities/rosblancos/pdf-utilities/pdf-element-extractor.py", line 1, in <module>
import camelot
File "/~/.conda/envs/Utilities/lib/python3.7/site-packages/camelot/__init__.py", line 6, in <module>
from .io import read_pdf
File "/~/.conda/envs/Utilities/lib/python3.7/site-packages/camelot/io.py", line 5, in <module>
from .handlers import PDFHandler
File "/~/.conda/envs/Utilities/lib/python3.7/site-packages/camelot/handlers.py", line 9, in <module>
from .parsers import Stream, Lattice
File "/~/.conda/envs/Utilities/lib/python3.7/site-packages/camelot/parsers/__init__.py", line 4, in <module>
from .lattice import Lattice
File "/~/.conda/envs/Utilities/lib/python3.7/site-packages/camelot/parsers/lattice.py", line 27, in <module>
from ..image_processing import (
File "/~/.conda/envs/Utilities/lib/python3.7/site-packages/camelot/image_processing.py", line 5, in <module>
import cv2
ImportError: dlopen(/~/.conda/envs/Utilities/lib/python3.7/site-packages/cv2.cpython-37m-darwin.so, 2): Library not loaded: #rpath/libglib-2.0.0.dylib
Referenced from: /~/.conda/envs/Utilities/lib/libharfbuzz.0.dylib
Reason: Incompatible library version: libharfbuzz.0.dylib requires version 5601.0.0 or later, but libglib-2.0.0.dylib provides version 0.0.0
Process finished with exit code 1
I googled the error above and found this issue. However, I am unable to solve this issue as I am not able to find out what I need to do with the file named libglib.
Doing this worked for me:
pip install opencv-python

OSError importing python-igraph

I am trying to import igraph but it keeps throwing this error at me:
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/igraph/__init__.py",
line 36, in <module>
from igraph.clustering import *
File "/usr/local/lib/python3.6/site-packages/igraph/clustering.py",
line 36, in <module>
from igraph.drawing.colors import ClusterColoringPalette
File "/usr/local/lib/python3.6/site-
packages/igraph/drawing/__init__.py", line 27, in <module>
from igraph.drawing.graph import DefaultGraphDrawer
File "/usr/local/lib/python3.6/site-
packages/igraph/drawing/graph.py", line 27, in <module>
from igraph.drawing.edge import ArrowEdgeDrawer
File "/usr/local/lib/python3.6/site-packages/igraph/drawing/edge.py",
line 17, in <module>
cairo = find_cairo()
File "/usr/local/lib/python3.6/site-
packages/igraph/drawing/utils.py", line 413, in find_cairo
module = __import__(module_name)
File "/usr/local/lib/python3.6/site-packages/cairocffi/__init__.py",
line 41, in <module>
cairo = dlopen(ffi, 'cairo', 'cairo-2')
File "/usr/local/lib/python3.6/site-packages/cairocffi/__init__.py",
line 38, in dlopen
raise OSError("dlopen() failed to load a library: %s" % ' /
'.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2
I have tried to follow this guide to install cairo but it throws this error and doesn't solve the igraph import issue: error: mandatory image surface backend feature could not be enabled
I have also tried to install pycairo but that resulted in no module founds: cairo, which brought me back to square one.
I tried running sudo port install cairo as per https://cairographics.org/download/ instructions. But that results in Error: Port cairo not found
My sys config:
MacOS High Sierra 10.13.1
Python 3.6
python-igraph 0.7.1
I am clueless as to what can be the issue. Any help would be highly appreciated. Thank you :)
Thanks to #Aiven I have managed to solve my issue. If anyone ever comes across the same problem, this have done the trick for me:
brew install cairo
brew install py2cairo
brew install igraph (install C-core)
sudo pip install python-igraph (install igraph for python)

ImportError: No module named _bsddb

I had some problems with upgrading matplotlib recently so I ended up installing different versions of Python on my Mac (Sierra) via brew, and then uninstalled afterwards. However, now matplotlib works (2.0.2) but whenever I run a particular python script that used to work I get an error which I didn't have before:
Traceback (most recent call last):
File "sim.py", line 254, in <module>
main()
File "sim.py", line 118, in main
db = shelve.open('.sim_balance', 'c')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shelve.py", line 243, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shelve.py", line 227, in __init__
Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/anydbm.py", line 84, in open
mod = __import__(result)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/dbhash.py", line 7, in <module>
import bsddb
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bsddb/__init__.py", line 67, in <module>
import _bsddb
ImportError: No module named _bsddb
According to my searches online this has something to do with my brew installed python interfering? I also deleted all my files in /Library/Python/2.7/site-packages yesterday which may have caused this as well.
I have tried homebrew brew install berkeley-db but then pip install bsddb3 yields:
Terrys-MBP:site-packages Terry$ pip install bsddb3
Collecting bsddb3
Using cached bsddb3-6.2.4.tar.gz
Complete output from command python setup.py egg_info:
Can't find a local Berkeley DB installation.
(suggestion: try the --berkeley-db=/path/to/bsddb option)
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/m5/1fg5rnj11_9cz5pntlqlwzyc0000gn/T/pip-build-elBAFK/bsddb3/
EDIT: Solved. Installed anaconda, installed bsddb via conda install and everything is working now.
Solved. I Installed anaconda, installed bsddb via conda install and everything is working now.

Anaconda Installation error on MAc OS

I am tyying to install anaconda on my mac but at the last step of installtion it gives me following error:
installing: conda-env-2.4.5-py27_0 ...
Python 2.7.11 :: Continuum Analytics, Inc.
creating default environment...
Traceback (most recent call last):
File "/Users/sdb99/anaconda2/pkgs/conda-4.0.5-py27_0/lib/python2.7/site-packages/conda/install.py", line 37, in <module>
import subprocess
File "/Users/sdb99/anaconda2/pkgs/python-2.7.11-0/lib/python2.7/subprocess.py", line 430, in <module>
import pickle
File "/Users/sdb99/anaconda2/pkgs/python-2.7.11-0/lib/python2.7/pickle.py", line 1272, in <module>
import binascii as _binascii
ImportError: dlopen(/Users/sdb99/anaconda2/pkgs/python-2.7.11-0/lib/python2.7/lib-dynload/binascii.so, 2): Library not loaded: #loader_path/../../libz.1.dylib
Referenced from: /Users/sdb99/anaconda2/pkgs/python-2.7.11-0/lib/python2.7/lib-dynload/binascii.so
Reason: image not found
Any idea how i can get ahead from here?
Thanks!
Just update python to the next version and try installing Anaconda again.
I had python 2.7 and then I updated it to python 3 and I was able to install Anaconda graphical installer successfully.

Categories