I am trying to update my matplotlib
in virtualenv and now it seems everything crashed :(
what I did till now is basically,
source ~/myenv/bin/activate
pip install -U matplotlib
I had previously matplotlib 1.3
now if I activate py virtual environment and check the matplotlib version
it shows 2.1
but I cannot import Axes3D
from matplotlib.
>>> import importlib
>>> importlib.import_module('mpl_toolkits.mplot3d').__path__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/nld/python-2.7.6-freya/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/usr/vir_python/lib/python2.7/site-packages/mpl_toolkits/mplot3d/__init__.py", line 6, in <module>
from .axes3d import Axes3D
File "/home/usr/vir_python/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 32, in <module>
from matplotlib.cbook import _backports
ImportError: cannot import name _backports
I working on linux platform and using Python 2.7.
Further problem, I saw,
If I just open virtual python, without activating the virtualenv, I get matplotlib 2.1
$:~> myenv/bin/python
Python 2.7.6 (default, Apr 15 2014, 11:17:36)
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'2.1.0'
but if I activate the virtual environment and then open the virtual python with I get matplotlib 1.3.1
or old matplotlib.
$:~> source myenv/bin/activate
(vir_python)$:~> myenv/bin/python
Python 2.7.6 (default, Apr 15 2014, 11:17:36)
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'1.3.1'
I did the following as per Karthik's suggestion :
First activated the virtual python
(vir_python) $: pip install matplotlib==2.1.0
(vir_python) $: pip freeze
backports.functools-lru-cache==1.4
backports.ssl-match-hostname==3.4.0.2
cycler==0.10.0
imageio==2.1.2
Jinja2==2.7.2
MarkupSafe==0.19
matplotlib==1.3.1
mpi4py==2.0.0
nose==1.3.1
numpy==1.12.0
olefile==0.44
pandas==0.19.2
Pillow==4.0.0
pyparsing==2.0.1
python-dateutil==2.6.0
pytz==2016.10
scipy==0.19.0
six==1.10.0
subprocess32==3.2.7
svg.path==1.1
tornado==3.2
virtualenv==1.11.4
To get the latest version of pip, you would need to run (in the activated venv): python3 -m pip install --upgrade pip just as you needed to do to upgrade the system-wide instance of python3 to the latest pip.
Matplotlib can be installed using pip. The following command is run in the command prompt to install Matplotlib. This command will start downloading and installing packages related to the matplotlib library. Once done, the message of successful installation will be displayed.
To update installed packages to the latest version, run pip install with the --upgrade or -U option.
go to command prompt. and use this command. python -m pip install -–upgrade pip. Dont forget to restart the editor,to avoid any error.
plt.__version__
>> 3.0.0
this is current version of matplotlib in my system. In the terminal, give the following comments:
$source activate envname
$pip install --upgrade matplotlib
In python prompt,
import matplotlib as plt
plt.__version__
>> 3.0.2
updates the existing version
Your virtualenv has a local matplotlib installed. After sourcing activate, upgrade matplotlib using
pip install matplotlib==2.1.0
or
pip install --upgrade matplotlib
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With