I'm trying to use Mayavi in Python 2.7, but cannot import it. My OS is Ubuntu (LTS). Here is the code:
import numpy
from mayavi.mlab import *
The following error is produced:
Traceback (most recent call last):
File "/path/to/my/script/my_script_name.py", line 2, in <module>
from mayavi import mlab
File "/usr/local/lib/python2.7/dist-packages/mayavi/mlab.py", line 16, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "/usr/local/lib/python2.7/dist-packages/mayavi/tools/camera.py", line 24, in <module>
from .engine_manager import get_engine
File "/usr/local/lib/python2.7/dist-packages/mayavi/tools/engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "/usr/local/lib/python2.7/dist-packages/mayavi/preferences/api.py", line 4, in <module>
from .preference_manager import preference_manager
File "/usr/local/lib/python2.7/dist-packages/mayavi/preferences/preference_manager.py", line 30, in <module>
from apptools.preferences.api import (ScopedPreferences, IPreferences,
File "/usr/lib/python2.7/dist-packages/apptools/preferences/api.py", line 4, in <module>
from preferences import Preferences
File "/usr/lib/python2.7/dist-packages/apptools/preferences/preferences.py", line 9, in <module>
from traits.api import Property, Str, Undefined, implements
ImportError: cannot import name implements
I have tried force-reinstalling the packages mayavi, implements, traits, but to no avail. I tried both with pip and with apt.
Edit: I think the error is that mayavi cannot access VTK for my Python 2.7 installation. When I try to pip force-reinstall mayavi, I get the error "Could not find any downloads that satisfy the requirement vtk (from mayavi)". That error is described here. I do not know what to do, since both vtk and vtkpython are properly installed (with apt) and working - the issue is with mayavi and pip not knowing what to do?
Related
I'm trying to run my Python program and these are the modules I'm importing:
from tkinter import *
from functools import partial
import numpy as np import
matplotlib matplotlib.use("TkAgg")
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg
import FigureCanvasTkAgg, NavigationToolbar2Tk
I always end up with the following error message:
C:\Users\HP\anaconda3\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "ASRS.py", line 12, in <module>
from matplotlib.figure import Figure
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\figure.py", line 18, in <module>
from matplotlib import docstring, projections
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\projections\__init__.py", line 1, in <module>
from .. import axes, docstring
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\axes\__init__.py", line 1, in <module>
from ._subplots import *
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\axes\_subplots.py", line 6, in <module>
from matplotlib.axes._axes import Axes
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\axes\_axes.py", line 14, in <module>
import matplotlib.contour as mcontour
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\contour.py", line 17, in <module>
import matplotlib.text as text
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\text.py", line 16, in <module>
from .textpath import TextPath # Unused, but imported by others.
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\textpath.py", line 11, in <module>
from matplotlib.mathtext import MathTextParser
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\mathtext.py", line 27, in <module>
from PIL import Image
File "C:\Users\HP\anaconda3\lib\site-packages\PIL\Image.py", line 94, in <module>
from . import _imaging as core
**ImportError: DLL load failed while importing _imaging: Belirtilen modül bulunamadı.**
How can I fix this?
Simply upgrading the package "Pillow" (using the Anaconda environment) worked for me to resolve this issue.
pip install --upgrade Pillow
I am an amateur programmer. I am trying to use:
import thinkdsp as dsp
import thinkplot as plt
I have installed the pip install thinkx module but I keep getting that error and I don't understand why. I will leave what the console shows down below:
Traceback (most recent call last):
File "Karaokemaker1.py", line 1, in <module>
import thinkdsp as dsp
File "C:\Users\keigo\anaconda3\lib\site-packages\thinkdsp.py", line 17, in <module>
import scipy.stats
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\stats\__init__.py", line 384, in <module>
from .stats import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\stats\stats.py", line 185, in <module>
from . import distributions
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\stats\distributions.py", line 10, in <module>
from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 25, in <module>
from scipy import optimize
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\optimize\__init__.py", line 390, in <module>
from ._minimize import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\optimize\_minimize.py", line 30, in <module>
from ._trustregion_constr import _minimize_trustregion_constr
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\optimize\_trustregion_constr\__init__.py", line 4, in <module>
from .minimize_trustregion_constr import _minimize_trustregion_constr
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\optimize\_trustregion_constr\minimize_trustregion_constr.py", line 4, in <module>
from scipy.sparse.linalg import LinearOperator
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py", line 116, in <module>
from .eigen import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py", line 11, in <module>
from .arpack import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py", line 22, in <module>
from .arpack import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py", line 45, in <module>
from . import _arpack
ImportError: DLL load failed: The specified procedure could not be found.
I assumed the issue was with the scipy because all the following errors come from that module. I checked and I have everything installed properly for the scipy module.
Please help! Thank you!
Run any command prompt you are using as administrator and then run pip install lib_name --force-reinstall
Try using these two commands they will help you:
conda remove --force scipy
And:
pip install scipy
Hello I had the same issue than you. Depend on wich version of python you use you should choose a version thinkx. I recommend you to go on the website of thinkx and check out for past udapte. In my case that was with matplotlib 3.3.1 for python 3.7. I went in git bash and used
pip install matplotlib==3.0.1
and everything worked. I had the same issue with seaborn and it worked.
I'm trying to use mayavi in python to visualize a pointcloud, and cannot resolve this error. I'm sure it is an easy pip install, but I am unsure of the command. Any help is much appreciated! Thanks!
BTW, I am running Ubuntu 18.04 and have tried installing scipy as mentioned here: Python import error "getfullargspec". I have also ran pip install traitsui. Additionally, I have rebooted my system.
Update:
After further digging, it appears that it may be an issue with Python versions. I was able to get it to run with Python3, but not Python 2.7 (I need it to work with python 2). I have also tried modifying the code within handler.py to getargspec instead of getfullargspec. I was given an error about trait_factory by doing this
Here is the entire printout:
Traceback (most recent call last):
File "mayavi_test.py", line 3, in <module>
from mayavi import mlab
File "/home/user/.local/lib/python2.7/site-packages/mayavi/mlab.py", line 16, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "/home/user/.local/lib/python2.7/site-packages/mayavi/tools/camera.py", line 24, in <module>
from .engine_manager import get_engine
File "/home/user/.local/lib/python2.7/site-packages/mayavi/tools/engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "/home/user/.local/lib/python2.7/site-packages/mayavi/preferences/api.py", line 4, in <module>
from .preference_manager import preference_manager
File "/home/user/.local/lib/python2.7/site-packages/mayavi/preferences/preference_manager.py", line 29, in <module>
from traitsui.api import View, Group, Item
File "/home/user/.local/lib/python2.7/site-packages/traitsui/api.py", line 37, in <module>
from .editors.api import (
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/__init__.py", line 26, in <module>
from .api import (
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/api.py", line 6, in <module>
from .array_editor import ArrayEditor
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/array_editor.py", line 34, in <module>
from ..view import View
File "/home/user/.local/lib/python2.7/site-packages/traitsui/view.py", line 41, in <module>
from .ui import UI
File "/home/user/.local/lib/python2.7/site-packages/traitsui/ui.py", line 51, in <module>
from .handler import Handler, ViewHandler
File "/home/user/.local/lib/python2.7/site-packages/traitsui/handler.py", line 27, in <module>
from inspect import getfullargspec
ImportError: cannot import name getfullargspec
The solution for this problem was to use older packages. Not all of the dependencies such as traitsui are compatible with Python 2.7. Even though an older version of mayavi was installed, the dependencies that are installed automatically are not compatible (they only support Python 3).
Here are the versions that work well together for me:
mayavi==4.6.2
traitsui==6.1.3
traits==5.2.0
numpy==1.17.4
pyface==6.1.2
To install a specific version, just run sudo pip install packageName==#.#.#
I am trying to plot with geopandas with this [tutorial][1]. However, whenever I run this: I find following errors:
Traceback (most recent call last):
File "/home/mahin/PycharmProjects/ProfessorEick-20191013T041703Z-001/ProfessorEick/KernelDensity2D/GeoPandasPlot.py", line 2, in <module>
import geoplot
File "/home/mahin/miniconda3/lib/python3.7/site-packages/geoplot/__init__.py", line 1, in <module>
from .geoplot import (
File "/home/mahin/miniconda3/lib/python3.7/site-packages/geoplot/geoplot.py", line 17, in <module>
import contextily as ctx
File "/home/mahin/miniconda3/lib/python3.7/site-packages/contextily/__init__.py", line 7, in <module>
from .place import Place, plot_map
File "/home/mahin/miniconda3/lib/python3.7/site-packages/contextily/place.py", line 6, in <module>
from .tile import howmany, bounds2raster, bounds2img, _sm2ll, _calculate_zoom
File "/home/mahin/miniconda3/lib/python3.7/site-packages/contextily/tile.py", line 20, in <module>
from rasterio.io import MemoryFile
ModuleNotFoundError: No module named 'rasterio.io'
I have tried installing rasterio using conda from the following link and also using the following instructions. However, the problem still exists. Anybody knows what could be the reason? My operating system is Ubuntu 18.06, I am running the code using pyccharm and my python version is 3.7.
The problem is likely a configuration issue, because getting the installation correct on Macs seems to be tricky. I'm running Mavericks and matplotlib 1.4.x, yet when I open a Python 2.7.5 shell and import pylib, I get this error:
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/pylab.py", line 230, in <module>
import matplotlib.finance
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/finance.py", line 38, in <module>
from matplotlib.collections import LineCollection, PolyCollection
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 55, in <module>
import matplotlib.textpath as textpath
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/mathtext.py", line 64, in <module>
import matplotlib._png as _png
ImportError: dlopen(/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/_png.so, 2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/_png.so
Reason: image not found
I have libpng16 installed, but not libpng15.
I saw a hardcoded reference to libpng15 in _png.so.
Uninstall and install of matplotlib fixed the issue for me.
You can always moke it by generating a soft link like this
sudo ln -s /opt/X11/lib/libpng.dylib /usr/local/lib/libpng15.15.dylib
Not the cleaner solution but I haven't figure out why matplotlib stubbornly asks specifically for libpng15 and not any 15 or greater.