skip to Main Content

I installed Ubuntu 20.04, and python3 (3.8) is installed by default.
To install python3.9, I executed:

sudo apt install python3.9

Thus, I have two versions of Python at my laptop: 3.8 and 3.9.

I’m trying to launch the simple script:

import numpy

With Python 3.8 it works correctly. But, when I interp my script by Python 3.9 the error occurs:

enter image description here

How to solve this problem?

I’ve already tried to update numpy using pip, nothing has happened.

pip3 install numpy --upgrade

2

Answers


  1. You can install a package for a specific version of Python with

    python3.9 -m pip install numpy
    

    For a more consistent python environment look at python venv or a container.

    Login or Signup to reply.
  2. Likely what is happening here is, because you have 2 versions of python installed, your pip3 command is only installing things for one of the versions, 3.8 in this case.

    Specifying the python version you want to run your command with will help solve this issue.

    For example,

    python3.9 -m pip install numpy
    

    or

    python3.8 -m pip install numpy
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search