can't upgrade to ubuntu 18.04 LTS from 16.04.7 LTS

Asked by Umair

i run sudo do-release-upgrade but it gives me the following error

  Traceback (most recent call last):
    File "/usr/lib/python3.5/site.py", line 173, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/home/dev/.local/lib/python3.5/site-packages/_distutils_hack/__init__.py", line 184
      return os.path.basename(__main__.__file__) == f'{name}.py'
                                                               ^
  SyntaxError: invalid syntax

  Remainder of file ignored
  Checking for a new Ubuntu release
  Get:1 Upgrade tool signature [819 B]
  Get:2 Upgrade tool [1,251 kB]
  Fetched 1,252 kB in 0s (0 B/s)
  authenticate 'bionic.tar.gz' against 'bionic.tar.gz.gpg'
  extracting 'bionic.tar.gz'
  Error processing line 1 of /home/dev/.local/lib/python3.5/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/usr/lib/python3.5/site.py", line 173, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/home/dev/.local/lib/python3.5/site-packages/_distutils_hack/__init__.py", line 184
      return os.path.basename(__main__.__file__) == f'{name}.py'
                                                               ^
  SyntaxError: invalid syntax

  Remainder of file ignored

i run sudo do-release-upgrade but it gives me the following error

  Traceback (most recent call last):
    File "/usr/lib/python3.5/site.py", line 173, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/home/dev/.local/lib/python3.5/site-packages/_distutils_hack/__init__.py", line 184
      return os.path.basename(__main__.__file__) == f'{name}.py'
                                                               ^
  SyntaxError: invalid syntax

Remainder of file ignored
Checking for a new Ubuntu release
Get:1 Upgrade tool signature [819 B]
Get:2 Upgrade tool [1,251 kB]
Fetched 1,252 kB in 0s (0 B/s)
authenticate 'bionic.tar.gz' against 'bionic.tar.gz.gpg'
extracting 'bionic.tar.gz'
Error processing line 1 of /home/dev/.local/lib/python3.5/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/usr/lib/python3.5/site.py", line 173, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/home/dev/.local/lib/python3.5/site-packages/_distutils_hack/__init__.py", line 184
      return os.path.basename(__main__.__file__) == f'{name}.py'
                                                               ^
  SyntaxError: invalid syntax

Remainder of file ignored
before above command I run following commands: sudo apt update; sudo apt upgrade

current version of ubuntu is 16.04.7 LTS and I'm willing to upgrade to latest LTS.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu ubuntu-release-upgrader Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

I assume this is caused by your non-standard python installation (/home/dev/.local/lib/python3.5)

What is the output of the commands

command -v python
echo $PATH
ls -l /usr/bin/python{,2,3}

Revision history for this message
Umair (123umair) said (last edit ):
#2

Here it is:
dev@dev-HP-EliteBook-840-G3:~$ command -v python
/usr/bin/python

dev@dev-HP-EliteBook-840-G3:~$ echo $PATH
/home/dev/.nvm/versions/node/v16.13.1/bin:/home/dev/.rbenv/plugins/ruby-build/bin:/home/dev/.rbenv/shims:/home/dev/.rbenv/bin:/home/dev/.rbenv/shims:/home/dev/.rbenv/bin:/home/dev/.cargo/bin:/home/dev/bin:/home/dev/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/dev/.rvm/bin:/home/dev/.rvm/bin

dev@dev-HP-EliteBook-840-G3:~$ ls -l /usr/bin/python{,2,3}
lrwxrwxrwx 1 root root 24 Jun 26 09:24 /usr/bin/python -> /etc/alternatives/python
lrwxrwxrwx 1 root root 9 Aug 3 2021 /usr/bin/python2 -> python2.7
lrwxrwxrwx 1 root root 9 Aug 3 2021 /usr/bin/python3 -> python3.5
dev@dev-HP-EliteBook-840-G3:~$

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

Ok, and what's now the output of

ls -l /etc/alternatives/python /usr/bin/python{2.7,3.5}
python --version

Revision history for this message
Umair (123umair) said :
#4

dev@dev-HP-EliteBook-840-G3:~$ ls -l /etc/alternatives/python /usr/bin/python{2.7,3.5}
lrwxrwxrwx 1 root root 16 Jun 26 09:24 /etc/alternatives/python -> /usr/bin/python3
-rwxr-xr-x 1 root root 3492624 Mar 2 2021 /usr/bin/python2.7
-rwxr-xr-x 2 root root 4456208 Jan 26 2021 /usr/bin/python3.5

dev@dev-HP-EliteBook-840-G3:~$ python --version
Python 3.5.2

Revision history for this message
Manfred Hampl (m-hampl) said :
#5

I suggest that you try reconfiguring python such that the command "python" starts python2 (to be exact python 2.7)
Maybe that helps.
If this does not work, then you should (at least temporarily) remove /home/dev/.local from your PATH settings and try again.
If that fails also, then I recommend a clean new installation (not of Ubuntu 18.04 but better 22.04, eventually 20.04).

Can you help with this problem?

Provide an answer of your own, or ask Umair for more information if necessary.

To post a message you must log in.