I am unable to import pylab using the latest version of Anaconda (Linux 64 bit). Other packages seem to work fine. (Note: I don't have sudo access)
In [1]: import pylab as pl
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-2cf12a0af6ff> in <module>()
----> 1 import pylab as pl
/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/pylab.py in <module>()
----> 1 from matplotlib.pylab import *
2 import matplotlib.pylab
3 __doc__ = matplotlib.pylab.__doc__
/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/matplotlib/pylab.py in <module>()
267 from numpy.linalg import *
268
--> 269 from matplotlib.pyplot import *
270
271 # provide the recommended module abbrevs in the pylab namespace
/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
96
97 from matplotlib.backends import pylab_setup
---> 98 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
99
100
/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
23 backend_name = 'matplotlib.backends.%s'%backend_name.lower()
24 backend_mod = __import__(backend_name,
---> 25 globals(),locals(),[backend_name])
26
27 # Things we pull in from all backends
/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py in <module>()
11
12 from backend_agg import FigureCanvasAgg
---> 13 from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
14 show, draw_if_interactive, backend_version, \
15 NavigationToolbar2QT
/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt4.py in <module>()
23 figureoptions = None
24
---> 25 from qt4_compat import QtCore, QtGui, _getSaveFileName, __version__
26
27 backend_version = __version__
/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/matplotlib/backends/qt4_compat.py in <module>()
34 # Now perform the imports.
35 if QT_API in (QT_API_PYQT, QT_API_PYQTv2):
---> 36 import sip
37 if QT_API == QT_API_PYQTv2:
38 if QT_API_ENV == 'pyqt':
ImportError: No module named sip
If I try
> conda install sip
I get:
Error: No packages found matching: sip
I also get errors with:
$ pip install sip 1
Downloading/unpacking sip
You are installing a potentially insecure and unverifiable file. Future v
ersions of pip will default to disallowing insecure files.
Downloading sip-4.15.2.zip (899kB): 899kB downloaded
Running setup.py egg_info for package sip
Traceback (most recent call last):
File "<string>", line 16, in <module>
IOError: [Errno 2] No such file or directory: '/tmp/pip_build_josh/
sip/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
IOError: [Errno 2] No such file or directory: '/tmp/pip_build_josh/sip/
setup.py'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build
_josh/sip
Storing complete log in /home/josh/.pip/pip.log
Any thoughts on why?
Just had this problem and it was related to which qt backend matplotlib was trying to use, try:
import PyQt4
If you don't have PyQt4 you probably have PySide
import PySide
If this is the case you need to set the matplotlib.rcParams['backend.qt4'] == 'PySide' not 'PyQt4'. You can also do this in your matplotlibrc file (~/.matplotlib/matplotlibrc)
# find and change line:
backend.qt4 : PySide
Note: if you don't have the matplotlibrc file you can copy it from the matplotlib source directory
import os
import matplotlib
mpl_dir = os.path.dirname(matplotlib.__file__)
os.system("cp {}/mpl-data/matplotlibrc ~/.matplotlib/".format(mpl_dir))
Following worked for me
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pylab as pl
Related
I am using python from a anaconda installation and using the python
notebook. From the jupyer notebook (ipython) I import fssa like:
import fssa
I get the following error message (see below).
Any help from you will be appreciated.
I have tried uninstalling and reinstalling scipy, numpy, and fssa and reinstalling
them, but the problem seems to remain.
ImportError Traceback (most recent call last)
/tmp/ipykernel_218856/781571052.py in <module>
----> 1 import fssa
~/anaconda3/lib/python3.9/site-packages/fssa/__init__.py in <module>
82
83 import pkg_resources
---> 84 from .fssa import scaledata, quality, autoscale
85
86 __version__ = pkg_resources.get_distribution(__name__).version
~/anaconda3/lib/python3.9/site-packages/fssa/fssa.py in <module>
46 import scipy.optimize
47
---> 48 from .optimize import _minimize_neldermead
49
50
~/anaconda3/lib/python3.9/site-packages/fssa/optimize.py in <module>
11 import numpy
12 from numpy import asfarray
---> 13 from scipy.optimize.optimize import (OptimizeResult,
14 _status_message, wrap_function)
15
ImportError: cannot import name 'wrap_function' from 'scipy.optimize.optimize'
(/home/debasish/anaconda3/lib/python3.9/site-packages/scipy/optimize/optimize.py)
I don't why but I am now experiencing this issue on mac. I installed everything trough anaconda. Everything was working fine before a Restart of the system
import fiona
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-4c762272c079> in <module>
----> 1 import fiona
/anaconda3/lib/python3.6/site-packages/fiona/__init__.py in <module>
81 os.environ["PATH"] = os.environ["PATH"] + ";" + libdir
82
---> 83 from fiona.collection import BytesCollection, Collection
84 from fiona.drvsupport import supported_drivers
85 from fiona.env import ensure_env_with_credentials, Env
/anaconda3/lib/python3.6/site-packages/fiona/collection.py in <module>
7
8 from fiona import compat, vfs
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
10 from fiona.ogrext import Session, WritingSession
11 from fiona.ogrext import buffer_to_virtual_file, remove_virtual_file, GEOMETRY_TYPES
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/fiona/ogrext.cpython-36m-darwin.so, 2): Library not loaded: #rpath/libpoppler.76.dylib
Referenced from: /anaconda3/lib/libgdal.20.dylib
Reason: image not found
I installed scikit-learn library in python using the command
pip install -U scikit-learn
When I am trying to import the library or it's module like
from sklearn.model_selection import train_test_split
or simply import sklearn
I am getting the error
ImportError Traceback (most recent call last)
<ipython-input-24-73edc048c06b> in <module>()
----> 1 from sklearn.model_selection import train_test_split
c:\users\ajain9\appdata\local\programs\python\python36-32\lib\site-packages\sklearn\__init__.py in <module>()
132 else:
133 from . import __check_build
--> 134 from .base import clone
135 __check_build # avoid flakes unused variable error
136
c:\users\ajain9\appdata\local\programs\python\python36-32\lib\site-packages\sklearn\base.py in <module>()
11 from scipy import sparse
12 from .externals import six
---> 13 from .utils.fixes import signature
14 from . import __version__
15
c:\users\ajain9\appdata\local\programs\python\python36-32\lib\site-packages\sklearn\utils\__init__.py in <module>()
7 import warnings
8
----> 9 from .murmurhash import murmurhash3_32
10 from .validation import (as_float_array,
11 assert_all_finite,
ImportError: cannot import name 'murmurhash3_32'
Any reason this error might be happening?
I am using Python version 3.6.3 Numpy v 1.13.3 pandas v 0.21.0
I am using windows
Try using virutalenv and install all the libraries required there, it worked for me.
I used pyenv to install pypy in windows bash, then use pip to install matplotlib, but when importing pyplot, I got a RunTimeError
In [1]: import matplotlib.pyplot as plt
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-1-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt
/home/zjshao/.pyenv/versions/pypy-5.3.1/site-packages/matplotlib/pyplot.pyc in <module>()
112
113 from matplotlib.backends import pylab_setup
--> 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
115
116 _IP_REGISTERED = None
/home/zjshao/.pyenv/versions/pypy-5.3.1/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
30 # imports. 0 means only perform absolute imports.
31 backend_mod = __import__(backend_name,
---> 32 globals(),locals(),[backend_name],0)
33
34 # Things we pull in from all backends
/home/zjshao/.pyenv/versions/pypy-5.3.1/site-packages/matplotlib/backends/backend_tkagg.pyc in <module>()
11
12 # Paint image to Tk photo blitter extension
---> 13 import matplotlib.backends.tkagg as tkagg
14
15 from matplotlib.backends.backend_agg import FigureCanvasAgg
/home/zjshao/.pyenv/versions/pypy-5.3.1/site-packages/matplotlib/backends/tkagg.pyc in <module>()
7 import numpy as np
8
----> 9 from matplotlib.backends import _tkagg
10
11 def blit(photoimage, aggimage, bbox=None, colormode=1):
RuntimeError: Cannot dlopen tkinter module file
In [2]:
So what can be the problem, and how to solve this problem?
Any suggestions would be appreciated!
Perhaps something wrong with your python installation. The best ways is delete python and reinstall.
I suggest you install python from Anaconda. It is 'next-click' installer (awesome for windows) which set python path environment variable, and have useful package pre-installed, including 'mathplotlib'.
I tried to import matplotlib.pyplot, however received an error relating to python-tk not being installed. It appears to be installed but I still appear to be receiving the error. Any help would be appricated. For further info, the output is below. Many thanks.
$ ipython
Python 2.7.7 (default, Jun 3 2014, 16:16:56)
Type "copyright", "credits" or "license" for more information.
IPython 2.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import numpy as np
In [2]: import matplotlib.pyplot as plt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt
/usr/lib/pymodules/python2.7/matplotlib/pyplot.py in <module>()
96
97 from matplotlib.backends import pylab_setup
---> 98 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
99
100
/usr/lib/pymodules/python2.7/matplotlib/backends/__init__.pyc in pylab_setup()
26 # imports. 0 means only perform absolute imports.
27 backend_mod = __import__(backend_name,
---> 28 globals(),locals(),[backend_name],0)
29
30 # Things we pull in from all backends
/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py in <module>()
6 import os.path
7
----> 8 import Tkinter as Tk, FileDialog
9
10 # Paint image to Tk photo blitter extension
/usr/lib/python2.7/lib-tk/Tkinter.py in <module>()
40 import _tkinter
41 except ImportError, msg:
---> 42 raise ImportError, str(msg) + ', please install the python-tk package'
43 tkinter = _tkinter # b/w compat for export
44 TclError = _tkinter.TclError
ImportError: libBLT.2.4.so.8.5: cannot open shared object file: No such file or directory, please install the python-tk package
No such file or directory, please install the python-tk package
Install the package using:
sudo apt-get install python-tk
As a temporary arrangement just do
mv libBLT.2.4.so.8.6 libBLT.2.4.so.8.5
under /usr/lib/ . It should work fine again
See debian bugreport:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751767
(as far as I know, matplotlib does not depend on "blt")