0

While working on a project, I changed my Ubuntu 20.04 default Python 3 version to Python 3.10, by doing the following changes

  1. in bashrc, added alias python3 = python3.10 and sourced it
  2. ln -sf python3.10 python3 to mean that "python3 command means python3.10"

I know I messed up and rolled back these by

  1. removing the first line from bash and sourcing
  2. running the same command in 2 but with 3.8 replacing 3.10

However, now whenever I do any pip or pip3 install, I get this

build-system@buildsystem-H310M-H-2-0:~$ pip3 install pyserial
Collecting pyserial
  Using cached pyserial-3.5-py2.py3-none-any.whl (90 kB)
Installing collected packages: pyserial
Successfully installed pyserial-3.5
ERROR: Exception:
Traceback (most recent call last):
  File "/home/build-system/.local/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/build-system/.local/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
    return func(self, options, args)
  File "/home/build-system/.local/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 553, in run
    self._handle_target_dir(
  File "/home/build-system/.local/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 563, in _handle_target_dir
    ensure_dir(target_dir)
  File "/home/build-system/.local/lib/python3.10/site-packages/pip/_internal/utils/misc.py", line 105, in ensure_dir
    os.makedirs(path)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  [Previous line repeated 4 more times]
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/Users'

Whenever I put commands to check for the current version such as

  1. python3 -V
  2. which python

I get 3.8.10. Is this the default for Ubuntu 20.04?

Please tell me why is this happening despite rolling back from 3.10 to 3.8(default) and what do I need to do to fix this?

3
  • It is very hard to fix after you replace the default version with another. Yes 20.04 is 3.8 and 22.04 is 3.10 Most Ubuntu apps need the default version of python they were installed with to work. The quickest way to fix is a re install of the OS.
    – David
    Nov 5, 2022 at 7:39
  • What does pip3 --version say? Contrary to David's, I'm not convinced this problem is hard to fix.
    – Hi-Angel
    Nov 5, 2022 at 13:35
  • 1
    The main problem here was, that while I was doing the fukup, I had somehow put a path starting from /Users in the config.h file whose job was to set the path pointing towards a location where newly installed packages would go. I changed the path to '/usr/lib/Python3.8', which it is supposed to be, since '/Users' was mean't for MacOS users, not Debian.
    – terminal_
    Nov 7, 2022 at 10:57

1 Answer 1

0

The main problem here was, that I had somehow put a path starting from /Users in the config.h file whose job was to set the path pointing towards a location where newly installed packages would go. I changed the path to '/usr/lib/Python3.8', which it is supposed to be, since '/Users' was meant for MacOS users, not Debian.

Therefore, this was a problem caused by putting a wrong path.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .