I am trying to install an older version of matplotlib in Python, but I am receiving a VersionConflict Error, and I'm not sure how to resolve it.
Here is what I've done:
!pip install matplotlib==3.2.1
import pkg_resources
pkg_resources.require("matplotlib==3.2.1")
import matplotlib.pyplot as plt
%matplotlib inline
The error that results is as follows:
---------------------------------------------------------------------------
VersionConflict Traceback (most recent call last)
/var/folders/r4/mv26mg5j7tg3bwssklnxqbj40000gp/T/ipykernel_44459/3120454378.py in <module>
1 import pkg_resources
----> 2 pkg_resources.require("matplotlib==3.2.1")
3 import matplotlib.pyplot as plt
4 get_ipython().run_line_magic('matplotlib', 'inline')
~/opt/anaconda3/lib/python3.9/site-packages/pkg_resources/__init__.py in require(self, *requirements)
884 included, even if they were already activated in this working set.
885 """
--> 886 needed = self.resolve(parse_requirements(requirements))
887
888 for dist in needed:
~/opt/anaconda3/lib/python3.9/site-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
775 # Oops, the "best" so far conflicts with a dependency
776 dependent_req = required_by[req]
--> 777 raise VersionConflict(dist, req).with_context(dependent_req)
778
779 # push the new requirements onto the stack
VersionConflict: (matplotlib 3.4.3 (/Users/deisert/opt/anaconda3/lib/python3.9/site-packages), Requirement.parse('matplotlib==3.2.1'))
What is the best way to remedy this?
Related
I am getting the ImportError: DLL load failed: The specified procedure could not be found. when importing the module seaborn.
My code is:
import seaborn as sns
sns.set()
Output:
ImportError Traceback (most recent call last)
<ipython-input-16-6f477838ac7f> in <module>
----> 1 import seaborn
D:\anaconda3\lib\site-packages\seaborn\__init__.py in <module>
1 # Capture the original matplotlib rcParams
----> 2 import matplotlib as mpl
3 _orig_rc_params = mpl.rcParams.copy()
4
5 # Import seaborn objects
D:\anaconda3\lib\site-packages\matplotlib\__init__.py in <module>
205
206
--> 207 _check_versions()
208
209
D:\anaconda3\lib\site-packages\matplotlib\__init__.py in _check_versions()
190 # Quickfix to ensure Microsoft Visual C++ redistributable
191 # DLLs are loaded before importing kiwisolver
--> 192 from . import ft2font
193
194 for modname, minver in [
ImportError: DLL load failed: The specified procedure could not be found.
I have uninstalled and reinstalled seaborn. still problem is not solved. What should I do?
I just got your issue with both seaborn and matplotlib. Did you try executing matplotlib ? Searching for an answer, I found out that it might be related to the matplotlib actual version (3.3.1). Here's the StackOverflow post that helped me.
from matplotlib import ft2font: "ImportError: DLL load failed: The specified procedure could not be found."
I just deleted/uninstalled matplotlib from my current packages (I work in a virtual env), and reinstalled a previous version (3.0.3)
I was having the same issue with importing seaborn in jupyter lab, lately.
I uninstalled the seaborn using pip:
pip uninstall seaborn
Then installed it again using pip:
pip install seaborn
This worked in my case.
Just on the sidenote, I also updated the whole conda enviroment using
conda update --all. But this might not be influential in this case.
I am currently trying to import some Python package(matplotlib, pandas & numpy) using Jupyter Notebook. However, when I try to do so, this error appears:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-0aa0b027fcb6> in <module>
----> 1 import numpy as np
~\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py in <module>
140 from . import _distributor_init
141
--> 142 from . import core
143 from .core import *
144 from . import compat
~\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py in <module>
21 # NOTE: would it change behavior to load ALL
22 # DLLs at this path vs. the name restriction?
---> 23 WinDLL(os.path.abspath(filename))
24 DLL_filenames.append(filename)
25 if len(DLL_filenames) > 1:
~\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
354
355 if handle is None:
--> 356 self._handle = _dlopen(self._name, mode)
357 else:
358 self._handle = handle
OSError: [WinError 193] %1 is not a valid Win32 application
I have already tried to install these packages using Anaconda prompt via conda install numpy, conda install pandas. I did not encounter such issues importing the package in IDLE using cmd. Any help is much appreciated.
Like you, I had done uninstall/reinstalls of Anaconda and numpy/pandas, uninstalled 32-bit versions, and various other suggestions that people made, but none of that worked. However, notice that the error is referencing ~\AppData\Roaming\Python\....
I was able to solve the problem by deleting ~\AppData\Roaming\Python.
I have just installed gdal into my Python3 root environment using conda:
conda install -c conda-forge gdal
Installation went fine with the usual updates of some dependencies. Now returning to some of my scripts, both netCDF4 and mpl_toolkits.basemap have stopped working. These are the errors I get:
from netCDF4 import Dataset
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-09694a7f0e01> in <module>()
----> 1 from netCDF4 import Dataset
2 import numpy as np
3 import matplotlib.pyplot as plt
4 from scipy.interpolate import griddata
5 from mpl_toolkits.basemap import Basemap
/anaconda3/lib/python3.6/site-packages/netCDF4/__init__.py in <module>()
1 # init for netCDF4. package
2 # Docstring comes from extension module _netCDF4.
----> 3 from ._netCDF4 import *
4 # Need explicit imports for names beginning with underscores
5 from ._netCDF4 import __doc__, __pdoc__
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/netCDF4/_netCDF4.cpython-36m-darwin.so, 2): Library not loaded: #rpath/libhdf5.101.dylib
Referenced from: /anaconda3/lib/python3.6/site-packages/netCDF4/_netCDF4.cpython-36m-darwin.so
Reason: image not found
from mpl_toolkits.basemap import Basemap
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-5fb601138328> in <module>()
3 import matplotlib.pyplot as plt
4 from scipy.interpolate import griddata
----> 5 from mpl_toolkits.basemap import Basemap
6 import numpy.ma as ma
7 import glob
/anaconda3/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py in <module>()
35 import numpy as np
36 import numpy.ma as ma
---> 37 import _geoslib
38 import functools
39
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/_geoslib.so, 2): Library not loaded: #rpath/libgeos-3.5.0.dylib
Referenced from: /anaconda3/lib/python3.6/site-packages/_geoslib.so
Reason: image not found
I have no idea what these errors mean, since those paths do exist. What is most baffling is that the netCDF4 and mpl_toolkits modules did not change (i.e. were not updated/downgraded) with the installation of gdal, so why now are they failing?
I'm at the end of my tether with problems like this. Fortunately I made a copy of my Python root directory before attempting this installation so I can now revert back to it (I've been here many times before).
I know about working in separate conda environments, but am I seriously supposed to install a new environment every time I want to use a new Python module? This not only takes up a lot of harddrive space but most inconveniently means adding new functionality to old codes is impossible (I want to use GDAL to plot some geotiffs using Basemap, which now does not work!).
I cannot imagine proficient Python users battling with these issues - so what am I doing wrong?
I'm using python 3.5 and i tried to import Axes3D from mpl_toolkitd.mplot3d but unfortunately i get this error:
In [1]: from mpl_toolkits.mplot3d import Axes3D
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-357f877dbd2b> in <module>()
----> 1 from mpl_toolkits.mplot3d import Axes3D
/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/__init__.py in <module>()
2 unicode_literals)
3
----> 4 from matplotlib.externals import six
5
6 from .axes3d import Axes3D
ImportError: No module named 'matplotlib.externals'
This might be arising due to duplicate installation of matplotlib in your system.
Usually pip installs all external packages to:
/usr/local/lib/python3.5/dist-packages/matplotlib
On the other hand, apt-get installs your packages in :
/usr/lib/python3/dist-packages/
Therefore, one way to resolve this would be try following (in order):
sudo apt-get remove python3-matplotlib
sudo pip3 install matplotib.
I am very new to installing my own programs and packages on linux, so please be gentle ;)
I am working on Linux Mint 17.3 (Rosa) 64 bit (Ubuntu Trusty) and am trying to run through the scikitlearn tutorials located here:
https://github.com/savarin/pyconuk-introtutorial
I have installed all the relevant packages using:
pip install numpy pandas sklearn ipython
and everything looks great until I start trying to import some things from related packages i.e.
from scipy.stats import mode
I see the following error code:
sam#samputer ~/Desktop $ ipython
In [1]: from scipy.stats import mode
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-a8b1ace850b6> in <module>()
----> 1 from scipy.stats import mode
/home/sam/anaconda2/lib/python2.7/site-packages/scipy/stats/__init__.py in <module>()
336 from __future__ import division, print_function, absolute_import
337
--> 338 from .stats import *
339 from .distributions import *
340 from .morestats import *
/home/sam/anaconda2/lib/python2.7/site-packages/scipy/stats/stats.py in <module>()
178 from scipy._lib.six import callable, string_types
179 from numpy import array, asarray, ma, zeros
--> 180 import scipy.special as special
181 import scipy.linalg as linalg
182 import numpy as np
/home/sam/anaconda2/lib/python2.7/site-packages/scipy/special/__init__.py in <module>()
625 from __future__ import division, print_function, absolute_import
626
--> 627 from ._ufuncs import *
628
629 from .basic import *
ImportError: libgfortran.so.1: cannot open shared object file: No such file or directory
I'm also running into issues when I try to link through to R for visualisation. I add this as it may shed further light on the issue:
In [11]: %%R
....: library(ggplot2)
....:
/home/sam/anaconda2/lib/python2.7/site-packages/rpy2/robjects /functions.py:106: UserWarning: Error in library(ggplot2) : there is no package called ‘ggplot2’
res = super(Function, self).__call__(*new_args, **new_kwargs)
Error in library(ggplot2) : there is no package called ‘ggplot2’
If anyone can help me understand these issues and offer me some lines/links to fix them, I would be extremely grateful, as my googling hasn't made much progress.
Cheers!
If you're using Anaconda you should try installing packges with conda install first rather than pip install if you can — actually all of the the packages you installed come with the standard Anaconda distribution, so I would try reinstalling this first (did you install miniconda?)
For your second question I'm guessing you'll need to install ggplot in R, I think you do this by running install.packages("ggplot2") in R.