I need to use the VTK library (with version 5.10 because I am working on an existing code) in python on my Windows 10 machine but I can not manage to import it without DLLImport error:
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\vtk\__init__.py", line 139, in <module>
__helper.refine_import_err('qvtk', 'vtkQtPython', exc)
File "C:\Python27\lib\site-packages\vtk\__helper.py", line 32, in refine_import_err
raise LinkError, str(exc)
vtk.__helper.LinkError: DLL load failed: The specified module could not be found.
I have installed PyQt4 4.11.4 and VTK 5.10.1 in 32 bits version (my Python 2.7.12 installation is 32 bits too), downloaded here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
I think the issue is related to the vtkQtPython pyd and dll (the files are vtkQtPython.pyd which tries to load vtkQtPythonD.dll:
>>> import qvtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "qvtk.py", line 5, in <module>
from vtkQtPython import *
ImportError: DLL load failed: The specified module could not be found.
>>> import vtkQtPython
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
Importing vtk using the latest version (7.0.0) does work, but is not compatible with the code I am working on. I have already tried uninstalling and set-up the whole installation again (all libraries and Python itself).
I hope you'll find some ideas, I still could not find any solution after hours struggling.
Related
I installed h5py through the package mingw64-i686-python-h5py in MSYS2. Importing it in a MinGW shell throws the following error:
Python 3.8.2 (default, Apr 9 2020, 14:12:45) [GCC 9.3.0 32 bit] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import h5py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:/msys64/mingw32/lib/python3.8/site-packages/h5py/__init__.py", line 34, in <module>
from . import version
File "C:/msys64/mingw32/lib/python3.8/site-packages/h5py/version.py", line 17, in <module>
from . import h5 as _h5
File "h5py/h5.pyx", line 1, in init h5py.h5
ImportError: DLL load failed while importing defs: The specified procedure could not be found.
Reinstalling the package did not fix it. I installed numpy the same way and it works just fine.
I am trying to use sklearn in Windows 7 with Python 3.5, via the pre-compiled Windows binaries at http://www.lfd.uci.edu/~gohlke/pythonlibs/
I have installed
dask-0.7.5-py2.py3-none-any.whl
scikit_learn-0.17-cp35-none-win_amd64.whl
scipy-0.16.1-cp35-none-win_amd64.whl
numpy-1.9.3+mkl-cp35-none-win_amd64.whl
pandas-0.17.1-cp35-none-win_amd64.whl
without any errors at install time. Following another SO thread with the same error, I made sure that C:/python35 is both in my Path and is set as the PYTHONPATH.
I also have Visual Studio 2013 C++ installed.
When I go to import sklearn I get this error:
C:\Users\user>python
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python35\lib\site-packages\sklearn\__init__.py", line 57, in <module>
from .base import clone
File "C:\Python35\lib\site-packages\sklearn\base.py", line 9, in <module>
from scipy import sparse
File "C:\Python35\lib\site-packages\scipy\sparse\__init__.py", line 213, in <module>
from .csr import *
File "C:\Python35\lib\site-packages\scipy\sparse\csr.py", line 13, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: DLL load failed: The specified module could not be found.
Update: BrianCain's suggestion to upgrade Visual Studio C++ to version 2015 worked!
I have a Python 2.7.8. 32-bit installed on Windows 10 64 bit. When I try to import numpy I get the following error:
ActivePython 2.7.8.10 (ActiveState Software Inc.) based on
Python 2.7.8 (default, Jul 2 2014, 19:50:44) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Igic\AppData\Roaming\Python\Python27\site-packages\numpy\__init__.py", line 137, in <module>
import add_newdocs
File "C:\Users\Igic\AppData\Roaming\Python\Python27\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Igic\AppData\Roaming\Python\Python27\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Users\Igic\AppData\Roaming\Python\Python27\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Users\Igic\AppData\Roaming\Python\Python27\site-packages\numpy\core\__init__.py", line 5, in <module>
import multiarray
ImportError: DLL load failed: %1 is not a valid Win32 application.
I have installed numpy-1.9.2+unoptimized-cp27-none-win32.whl from this page
From CGohlke's page:
The binaries are compatible with the official CPython distribution on Windows >=6.0. Chances are they don't work with custom Python distributions included with Blender, Maya, ArcGIS, OSGeo4W, ABAQUS, Cygwin, Pythonxy, Canopy, EPD, Anaconda, WinPython etc.
My guess is that the same is also true of ActivePython.
I would recommend either installing the official CPython Windows binary from here, or installing the Anaconda distribution from here, which comes with numpy, scipy, matplotlib and a raft of other scientific Python packages.
I have installed ActivePython 2.7 on Mac OS X 10.5. The main reason for this is to use pypm, the package manager. However, after installing ActivePython and setting up my .bash_profile file to use that version of Python, I encounter a lot of problems with the pypm-installed libraries. To install all of these modules, I just type
pypm install <package-name>
and this is how I got matplotlib, PyQt4, PIL, etc. The problem is that all of these appear to install with no problems, they place the correct .pth and .so files into the correct site-packages folder, and basic imports work fine. But I get the following errors.
First, here is what I see when checking for Python on my machine:
new-host:site-packages ely$ which python
/usr/local/bin/python
new-host:site-packages ely$ ls -l /usr/local/bin/python
lrwxr-xr-x 1 root wheel 60 May 25 22:15 /usr/local/bin/python -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python
Next, I invoke Python and attempt to import things.
new-host:site-packages ely$ python
ActivePython 2.7.1.4 (ActiveState Software Inc.) based on
Python 2.7.1 (r271:86832, Feb 7 2011, 11:33:10)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> from PyQt4 import QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(PyQt4/QtGui.so, 2): Library not loaded: QtGui.framework/Versions/4/QtGui
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/PyQt4/QtGui.so
Reason: image not found
So the above shows that PyQt4 imports with no complaints, but then I get the 'image not found' error when I try to use any of the sub-modules. For another example, here is the standard matplotlib.
>>> import matplotlib
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "matplotlib/pyplot.py", line 23, in <module>
from matplotlib.figure import Figure, figaspect
File "matplotlib/figure.py", line 16, in <module>
import artist
File "matplotlib/artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "matplotlib/transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: dlopen(matplotlib/_path.so, 2): Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/matplotlib/_path.so
Expected in: dynamic lookup
>>> from matplotlib import pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "matplotlib/pyplot.py", line 23, in <module>
from matplotlib.figure import Figure, figaspect
File "matplotlib/figure.py", line 16, in <module>
import artist
File "matplotlib/artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "matplotlib/transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: dlopen(matplotlib/_path.so, 2): Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/matplotlib/_path.so
Expected in: dynamic lookup
Any thoughts on why the pypm-installed versions are so problematic? I've used ActivePython and pypm on my Ubuntu work computer for a long time and never had any of these issues. Everything I've ever installed with pypm has worked beautifully. Why is it so different on Mac?
Make sure python and qt have same architecture (32bit vs 64bit)
for mathplot looks like a different g++ used to compile python and mathplot
have you tried with stock osx python?
Can someone please tell what this strange error is
Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 287, in HandlerDispatch
log=debug)
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 464, in import_module
module = imp.load_module(mname, f, p, d)
File "/project/django/django/core/handlers/modpython.py", line 4, in ?
from django import http
File "/project/django/django/http/__init__.py", line 3, in ?
from Cookie import SimpleCookie, CookieError
ImportError: No module named Cookie
Edit:
Python
Python 2.4.3 (#1, Jan 14 2008, 18:32:40)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Cookie import SimpleCookie, CookieError
>>> from http.Cookie import SimpleCookie, CookieError
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named http.Cookie
>>> import Cookie
>>> import http.Cookie
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named http.Cookie
>>> import http.Cookie
That you're missing the Cookie package (which is not part of Django), but it should be Builtin.
If you're using Python 3 please note that Cookie has been renamed to http.cookies, and that Django is incompatible with Python not 2.x.
That is what you're missing: http://docs.python.org/library/cookie.html.
Edit
I see you're running python 2.4. Consider switch to python 2.6 or 2.7, and check the presence of /usr/lib/python2.4/Cookie.py
Solution
The path was missing, so adding
sys.path.append('/usr/lib/python2.4/')
solves the issue.