I am trying to use python with mpi4py. However, when I run from mpi4py import MPI in a python environment, I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/mpi4py/MPI.so, 2): Library not loaded: /usr/local/lib/libmpi.1.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/mpi4py/MPI.so
Reason: image not found
In the specified path (/usr/local/lib/) I have what I think is a version of the required file called libmpi.12.dylib. I have looked at the source code for mpi4py and from what I can tell this file is valid, but for some reason mpi4py (MPI.so specifically) is still trying to use the .1. version.
The error message shown occurs whether I run using mpirun, mpiexec, or simply enter the import command in a terminal python session (the last one is how I generated the error message as copied here).
I would greatly appreciate any help on this. I have tried reinstalling and/or updating all the related packages and codes, but it has not solved the problem.
--- UPDATE ---
Out of desperation I tried renaming libmpi.12.dylib to libmpi.1.dylib and it worked, at least for now. I am still interested in a non-hack solution if anyone has one.
I think your problem should be resolved now, however, I had the exact same problem one iteration later;
ImportError: dlopen(/Users/<proj>/venv/lib/python3.5/site-packages/mpi4py/MPI.cpython-35m-darwin.so, 2):
Library not loaded: /usr/local/opt/open-mpi/lib/libmpi.12.dylib
Referenced from: /Users/<proj>/venv/lib/python3.5/site-packages/mpi4py/MPI.cpython-35m-darwin.so
Reason: image not found
My machine has a libmpi.20.dylib, but no libmpi.12.dylib, and although the source of mpi4py seems to check this, it did not work for me. My quick and dirty workaround was to make a symlink;
ln -s /usr/local/opt/open-mpi/lib/libmpi.20.dylib /usr/local/opt/open-mpi/lib/libmpi.12.dylib
And it worked (at least, it was able to load the library). Do note that I'm actually not using MPI locally, I'm just including the libraries so the code is more or less portable for the cluster.
-frbl
Related
I was following along a tutorial where they used the SpeechRecognition module, but when I made it to the first test it returns C:\Users\USER\PycharmProjects\Fatawi\venv\Scripts\python.exe C:/Users/USER/PycharmProjects/Fatawi/main.py Traceback (most recent call last): File "C:\Users\USER\PycharmProjects\Fatawi\main.py", line 1, in <module> import speech_recognition as sr ModuleNotFoundError: No module named 'speech_recognition'
I've tried reinstalling the library multiple times along with the PyAudio library. I ran the test that PyPi has for it and it works, but I don't know how fix it from here.
Check your python interpreter environment (the python version that's run the python file) maybe it's not the same version as python when you downloaded Speech Recognition.
Check if you activating the environemt.
For better understand see this blog in geeks for geeks might help you.
So aftergoing through some of the settings of the project file and checking the Python Interpreter it didn't have the SpeechRecognition Package. So I'm assuming that something went wrong with the install.
Thank you Faisal Faraj for the help.
I successfully installed dlib for python, following instructions here. However, when I try to import the library I get this message:
>>> import dlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/dlib/__init__.py", line 1, in <module>
from .dlib import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/dlib/dlib.so, 2): Library not loaded: #rpath/libpng16.16.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/dlib/dlib.so
Reason: image not found
I previously had(and uninstalled) anaconda and had the same issue in python 3.6. Looking at similar questions and responses it sounds like I would have to use install_name_tool command. However I do not know what the new path would be. I do not quite understand why this is necessary either. From what I know, the path that was referenced should have been fine. Why will dlib not import and what can I do to make it import successfully? Let me know. Thanks
I don't know if I would call this a solution, since I still have issues, but what I did was: install_name_tool -change #rpath/libpng16.16.dylib "/Library/Python/2.7/site-packages/dlib/dlib.so" /usr/local/lib/python2.7/site-packages/dlib/dlib.so
Although there was an additional problem with my installation, this fixed the problem at hand. I had dlib in my default python library rather than with a path similar to one in my virtual machine. So I changed the path to fit my VM and all my other installation packages(e.g boost and cmake)
I'm getting the error
Traceback (most recent call last):
File "ghs.py", line 1, in <module>
import stdio
ImportError: No module named stdio
When I try to run my script. I can run my script on other machines just fine. I have installed python using homebrew. And I've tried everything I can think of to get it to recognize my modules! I've uninstalled and reinstalled using brew. I've tried changing the path (though I don't fully understand this). I get no issues using brew doctor.
I've also tried using a python virtual environment but to no avail.
Any ideas on how to fix this issue or else 'start fresh' from a fresh version of python?
When you import a module, Python looks for it at the directory your code is, and the directory in which the built-in libraries are (C:\Users\pc\AppData\Local\Programs\Python\Python35-32\Lib in my case, I'm using Windows 10 and Python 3.5). If it can't find it, it raises ImportError.
I couldn't find a module named stdio in my computer. I also know some C++ and as far as I know, stdio is the library for inputs and outputs(prints). In python, there is no need to import such a library.
You can use try,except statement to test if your code works without importing the module like this.
try:
import stdio
except:
#rest of your code goes here
You will need to indent your whole code however this can be done easily with a text editor in which you can edit more than one line at a time.
We are using Python for .Net to call .NET API built using C# from Python script.
We are getting ImportError: No module named - error when an import is done as follows.
Python script:
import sys
sys.path.append(r"C:\myfolderA\myfolderB")
print sys.path
import clr
clr.FindAssembly(r"AA.BB.CC")
clr.AddReference(r"AA.BB.CC")
from AA.BB.CC.Api.DDInterface import DDClient
On the above line I am getting following error
Traceback (most recent call last):
File "C:\myfolderA\myfolderB\testAPI.py", line 7, in <module>
from AA.BB.CC.Api.DDInterface import DDClient
ImportError: No module named AA.BB.CC.Api.DDInterface
There is no other information available to exactly identify the issue.
Dlls from same project built 15 days back works fine.
This project may have gone through few changes in between.
How to exactly identify this issue?
Could this be a dependency issue?
I tried JustDecompile to compare old dlls and new ones, but couldn't find anything unusual.
Your help is deeply appreciated.
Thanks,
With help from python forum I was able to use Microsoft's Fuslogvw.exe (Assembly Binding Log Viewer) and figure out the dependent dll causing the error.
Thanks
Here is a link to my original answer:
https://mail.python.org/pipermail/pythondotnet/2014-December/001626.html
I recommend using Assembly Binding Log Viewer (fuslogvw.exe) for
corresponding .NET framework to see the log files of loading assemblies.
Set Log Location as Custom and in Settings point to your assemblies folder.
The log should show the sequence of DLLs being loaded and any errors.
This worked for me, see here:
Could not load file or assembly or one of its dependencies
Can't locate fuslogvw.exe on my machine
I am trying to load a *.pyd with Python, but I receive the well known "Import Error: DLL load failed: the specified procedure can not be found." error.
I have already done the following:
1.) Investigated the *.pyd with Dependency Walker. GPSVC.DLL and IESHIMS.DLL came up as missing, but delay loaded, IEFRAME.DLL aslo came up as missing an export, but was also delay-loaded. It's my understanding that these are not used, and are delay load anyway, so they should not be the problem.
2.) Did an "import foo" on foo.pyd in the python command window, with ProcMon watching. ProcMon shows event "LoadImage" on "foo.pyd" with result SUCCESS.
This seems to imply that the *.pyd file loaded correctly.
So what am I missing. My windows diagnostics are telling me all is well, but python is telling me the thing cannot be loaded (usually due to a missing dll or symbol).
Ideas?
Thanks!
Is the .pyd file for the same version of Python you're using? Loading a .pyd file for the wrong Python version can produce that error message.
Dependency Walker can show you which pythonNN.dll it links to.
If you have a file foo.pyd, for import foo to succeed, there must be an externally accessible function named initfoo. Dependency Walker will show this (typically the ONLY function) if it exists. initfoo needs to be called by Python to initialise the foo module.
Note: I would expect a more explicit error message if this were the problem:
>>> import fubar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initfubar)
>>>
You say that you are "trying to load a *.pyd file". Is that just a strange way of describing import foo or is it something else?
Did you create the pyd? If not, who did? Have you asked them? Is this pyd available on the web so that others could try to load/import it?
Ok here is the answer:
The windows diagnostics (depends, procmon, etc) were showing the DLL (or pyd) loading fine.
Python was showing that it was not loading fine.
I found that the windows tools were referring to a different Python26.dll hiding in my C:\Window\SysWOW64 folder.
This second Python26.dll (found in SysWOW64) has a symbol that is missing in the primary python26.dll (installed by the windows python installer, found in C:\Python26).
This symbol "_PyByteArray_empty_string", was apparently needed by my *.pyd file.
So when loading via windows diagnostics, the SysWOW64 dll was found, and the *.pyd loaded properly. When loading from python, the dll in C:\Python26\ was found, the symbol was missing, and load failed.
So that is WHY the problem manifested. The question now is: Why are there two versions of Python26.dll floating around, one with _PyByteArray_empty_string, and one without?
I'm using Python 2.6.6. Perhaps this symbol is removed in 2.6.6 but present in some older 2.6.x release?