Home > Enterprise >  Is Python and python3 in Linux has different pip?
Is Python and python3 in Linux has different pip?

Time:01-19

I installed Django on my Ubuntu 21.04 Software but when I use:

python manage.py runserver 

I get an error massage : No module named “Django” But when I use :

python3 manage.py runserve

It works fine but my python —-version is 3.10.1 and python3 —version is 3.9.x So what is the error and how I can run it with python only not python3

CodePudding user response:

If you use PIP3 to install the module, it will only be installed for Python3. If you use PIP to install the module, the system will use the Python version that is listed first in the PATH variable.

CodePudding user response:

The issue here is that the python and python3 commands are pointing to two different Python installations/environments altogether.

It looks like you installed Django in your Python 3.9.x environment (the one which you access by typing python3).

On the other hand, your Python 3.10.1 environment (which you access by writing python) seems to have no Django installed.

The pip/pip3 commands are sometimes confusing, and may point to a different Python installation than the one you think they do. This depends entirely on how you set up your Python environments in your machine.

In order to access the pip of a specific Python environment, the best way is to run it as a module, e.g.:

python -m pip [...]

This guarantees that the pip you're using is the one associated with the Python environment you're evoking with the python command.

So in order to install Django on your Python 3.10.1 environment, you need to run:

python -m pip install django
  •  Tags:  
  • Related