1

I am trying to get started with python on VS Code but I keep getting this error when I want to install the matplotlib library.

enter image description here

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Nelly Lopez
  • 17
  • 1
  • 1
  • 2
  • 3
    What about the error is not clear? It is very literal: you are using Python 2.7 and are using an outdated pip version. It is telling you to use Python 3.4+ and how to upgrade to the latest pip version. – Gino Mempin Aug 07 '21 at 01:27
  • I don't understand how its still using python 2.7 when I have python 3.9? @GinoMempin – Nelly Lopez Aug 07 '21 at 01:32
  • how do I make those changes? @Gino Mempin – Nelly Lopez Aug 07 '21 at 01:32
  • I was also able to update my pip version to pip 21.2.2 but the terminal is still saying that it is both python 2.7 and pip version 8? so that is why I need help @GinoMempin – Nelly Lopez Aug 07 '21 at 01:34
  • 3
    Try using the command `python3.9` instead of `python` in your terminal and `python3.9 -m pip` instead of `pip` – Iain Shelvington Aug 07 '21 at 01:35
  • 1
    Does this answer your question? [How do I access updated Python 3.9 in VS Code via command line?](https://stackoverflow.com/questions/67249134/how-do-i-access-updated-python-3-9-in-vs-code-via-command-line) – Gino Mempin Aug 07 '21 at 01:37
  • like so ... python3.9 -m pip install matplotlib ?? @IainShelvington – Nelly Lopez Aug 07 '21 at 01:39
  • Does this answer your question? [Dealing with multiple Python versions and PIP?](https://stackoverflow.com/q/2812520/2745495) – Gino Mempin Aug 07 '21 at 01:39
  • @NellyLopez yes that should work so long as python3.9 is available on your path – Iain Shelvington Aug 07 '21 at 01:43
  • 1
    Looks like you're using WSL which means that you need to be calling the Python binary with `python3` because you're trying to run your Python code on the Linux machine, not your Windows machine, so even though VS Code is set to the correct Python version, the subsytem you're attempting to run your code on isn't (again, because Linux and Mac both think the command `python` means "launch Python 2", which is fair since Python 2 is installed by default on Linux and MacOS). – ddejohn Aug 07 '21 at 03:10

7 Answers7

7

Consider using the --user option or check the permissions.

pip install -U --upgrade pip

kansensus
  • 71
  • 2
  • My upvote. I was getting the same message in `Azure Databricks`. I ran the command you suggested and it successfully upgraded pip from `20.2.4` to latest version `122.0.3` – nam Mar 02 '22 at 23:58
3

I tried a lot of different ones but the one below worked for me

pip3 install --upgrade pip --user
vine_J
  • 123
  • 6
0

Three things to do:

  1. Run this in your bash terminal

python3 pip install --upgrade pip

  1. Configure your VS Code environment for python 3.x

  2. Run your file using python3 [filename.py]

Primus
  • 36
  • 5
0

If the above suggestion fails, you should try:

pip install --upgrade pip  
Robert
  • 7,394
  • 40
  • 45
  • 64
p5ych
  • 9
  • 1
  • I run tried this. It gives me `Requirement already satisfied: pip in /Users/xxx` – wzso Jan 19 '22 at 09:18
  • Collecting pip Using cached https://files.pythonhosted.org/packages/46/28/addd7e66bb3af799d35a5dcbb79407b591a7ed674f4efd2bd8f930c40821/pip-22.2.1.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-86IKY3/pip/setup.py", line 7 def read(rel_path: str) -> str: ^ SyntaxError: invalid syntax ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-86IKY3/pip – Alexis Aug 01 '22 at 04:34
0

I added the folder than tried pip install --upgrade pip and it worked. You may have to show your hidden folders to follow the path.

0

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. To fix this problem, I'm trying to install it using this command: python -m pip install --upgrade pip setuptools virtualenv)

-1

You should use the command behind:

python3 install --upgrade pip
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
feloriten
  • 1
  • 1