Score:0

pip3 installs to python3.10 despite the later not being default Python version and shows permission denied

bn flag

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?

David avatar
cn flag
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.
Hi-Angel avatar
es flag
What does `pip3 --version` say? Contrary to David's, I'm not convinced this problem is hard to fix.
terminal_ avatar
bn flag
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.
Score:0
bn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.