2

I am trying to install matplotlib

pip install matplotlib

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: matplotlib in ./.local/lib/python2.7/site-packages (2.2.5)
Requirement already satisfied: python-dateutil>=2.1 in ./.local/lib/python2.7/site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: kiwisolver>=1.0.1 in ./.local/lib/python2.7/site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: numpy>=1.7.1 in ./.local/lib/python2.7/site-packages (from matplotlib) (1.16.6)
Requirement already satisfied: six>=1.10 in ./.local/lib/python2.7/site-packages (from matplotlib) (1.16.0)
Requirement already satisfied: cycler>=0.10 in ./.local/lib/python2.7/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in ./.local/lib/python2.7/site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: pytz in ./.local/lib/python2.7/site-packages (from matplotlib) (2021.3)
Requirement already satisfied: backports.functools-lru-cache in ./.local/lib/python2.7/site-packages (from matplotlib) (1.6.4)
Requirement already satisfied: subprocess32 in ./.local/lib/python2.7/site-packages (from matplotlib) (3.5.4)
Requirement already satisfied: setuptools in ./.local/lib/python2.7/site-packages (from kiwisolver>=1.0.1->matplotlib) (44.1.1)

when I try to verify the version installed

import matplotlib

matplotlib.version

I get this:

import-im6.q16: not authorized matplotlib' @error/constitute.c/WriteImage/1037.`

What is the problem? Thank you

Vale
  • 21
  • 4
  • 2
    I recommend using the [Anaconda Distribution](https://www.anaconda.com/products/individual), it's likely to make your life much easier. [Package List](https://docs.anaconda.com/anaconda/packages/py3.8_win-64/). If you are using Anaconda, do not use `pip` to install packages that exist within the `conda` ecosystem. Use `conda install package`. Only use `pip` if the package is not available with `conda install`. Using `pip` can potentially wreck your installation because `pip` and `conda` do not manage dependencies in the same way. – Trenton McKinney Dec 10 '21 at 19:29
  • When you run the installer it installs all the packages in the package list – Trenton McKinney Dec 10 '21 at 20:49
  • 1
    Why is anaconda being recommended? It is HUGE, comes with side-effects, and could cause more problems than it solves... – user2901351 May 15 '23 at 18:30

1 Answers1

2

Update

Looking into your error message in more detail, I found this answer.

It seems like your interpreter is not recognizing your script as python and is instead trying to use this tool.

Possibly try adding a shebang to your python file:

#!/usr/bin/env python3

Or run it explicitly with python:

# if /usr/bin/env python is python3
python myscript.py
# if not
python3 myscript.py

Original answer

It looks like you are trying to install with a Python2.7 pip. Python 2 is no longer really supported by anyone, so I recommend using Python 3 instead.

To install with python3, maybe try:

pip3 install matplotlib

If you want to update your default pip, you might try the following (see this answer):

pip install --upgrade pip

or

python -m pip install --upgrade pip

The comment to instead use conda is a good call also. Then you can simply do something like

conda create -n plots -c conda-forge python=3.9 matplotlib
conda activate plots

And matplotlib will be part of that python3 env.

Maximilian Press
  • 300
  • 4
  • 12
  • 1
    Hi @Maximilian Press, I tried `pip3 install matplotlib` but if I try to very the versio of matplotlib installed with `import matplotlib matplotlib.__version__` I get ` import-im6.q16: not authorized `matplotlib' @ error/constitute.c/WriteImage/1037.` – Vale Dec 10 '21 at 19:56
  • the default python is 3.9 for conda and matplotlib is installed by default so there's not a need to install a separate environment. – Trenton McKinney Dec 10 '21 at 19:57
  • @TrentonMcKinney I should download one of these? 64-Bit (x86) Installer (581 MB) 64-Bit (Power8 and Power9) Installer (255 MB) 64-Bit (AWS Graviton2 / ARM64) Installer (488 M) 64-bit (Linux on IBM Z & LinuxONE) Installer (242 M) and then run `conda install package`? – Vale Dec 10 '21 at 20:14
  • @Vale try the installer for the operating system you are using – Maximilian Press Dec 10 '21 at 21:24
  • well, I don't know what I've done... rigth now my situsation is this; pip -V pip 21.3.1 from /home/valeria/.local/lib/python3.6/site-packages/pip (python 3.6) python --version Python 3.6.9 python -m pip install -U matplotlib Defaulting to user installation because normal site-packages is not writeable – Vale Dec 11 '21 at 15:31
  • @Vale see my update from Friday. It looks like you are not running using the python interpreter. Instead follow suggested methods to run using the python interpreter. – Maximilian Press Dec 12 '21 at 21:51
  • Hi @MaximilianPress I tried but then I don't know what I did and I deleted packages on ubuntu, so I have to install ubuntu again. I did a mess. At the moment I haven't fixed it. Thank you anyway – Vale Dec 14 '21 at 12:30