I'm having challenges installing django using the command sudo python3.9 -m pip install Django
. The error I get running that command is:
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/lib/python3/dist-packages/pip/__main__.py", line 19, in <module>
sys.exit(pip.main())
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 242, in main
with self._build_session(
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 66, in _build_session
session = PipSession(
File "/usr/lib/python3/dist-packages/pip/download.py", line 321, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/lib/python3/dist-packages/pip/download.py", line 93, in user_agent
zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
It's been a hard time trying to run sudo python manage.py migrate
. From the comment/answer from this Stack Overflow post Traceback while running 'sudo python3 manage.py migrate' I got to know that I need python 3.6 and above. When I created the aws ubuntu server instance I ran python3 -V
and the ouput was that python3.5 was running on the machine. I upgraded it to python 3.9. Now when I run python3 -V
the output is: Python 3.9.4
. After upgrading to python3.9 I created and activated another virtual enviroment.
Now when I try to install django using the command sudo python3.9 -m pip install Django
I get the above error. If I use sudo python3 -m pip install Django
the django is installed with python3.5 because, thereafter when I run sudo python3 manage.py migrate
it throws back an error pointing to File "/usr/lib/python3.5/runpy.py", line 197, in _run_module_as_main
If I delete python 3.5 in /usr/lib
folder (since I still have python 3.9 there), python3.5 is recreated in the /usr/lib
folder whenever I reinstall django using sudo python3 -m pip install Django
(even if python3 -V
is outputting Python 3.9.4
). When I run sudo python3 manage.py migrate
it says I don't have django installed in my enviroment variable.
Now the explanation is getting boring. PLEASE HOW DO I INSTALL DJANGO ON UBUNTU AWS USING PYTHON3.9?