my python cannot install and I'm stuck and cannot do anything even though there are deadlines coming up. Here is wehat I tried:
pip install streamlit:
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/home/pc/.local/lib/python2.7/site-packages/pip/__init__.py", line 1, in <module>
from typing import List, Optional
ImportError: No module named typing
Then i saw that this doesn't install and decided that maybe the python version on the ubuntu is not the right one and so maybe need to make a virtual environment to install a new version of python:
sudo pip3 install virtualenvwrapper
[sudo] password for pc:
The directory '/home/pc/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/pc/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting virtualenvwrapper
Exception:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 140, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/connection.py", line 67, in create_connection
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.5/socket.py", line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 560, in urlopen
body=body, headers=headers)
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 787, in _validate_conn
conn.connect()
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 231, in connect
conn = self._new_conn()
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 149, in _new_conn
self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f114dfd9f60>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 317, in run
requirement_set.prepare_files(finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 360, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 512, in _prepare_file
finder, self.upgrade, require_hashes)
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 273, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/index.py", line 442, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3/dist-packages/pip/index.py", line 400, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3/dist-packages/pip/index.py", line 545, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3/dist-packages/pip/index.py", line 648, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3/dist-packages/pip/index.py", line 757, in get_page
"Cache-Control": "max-age=600",
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 492, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/pip/download.py", line 378, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 480, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 588, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/adapters.py", line 376, in send
timeout=timeout
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 610, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 238, in increment
total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
You are using pip version 8.1.1, however version 21.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
So the installation was not successful and it asks me to upgrade pip and so I did:
pip install --upgrade pip
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/home/pc/.local/lib/python2.7/site-packages/pip/__init__.py", line 1, in <module>
from typing import List, Optional
ImportError: No module named typing
So I thought maybe I take a look at the current installed python version:
python --version
Python 2.7.12
python3 --version
Python 3.5.2
Then I looked on-line and found that maybe we need to install typing as well:
pip install typing
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/home/pc/.local/lib/python2.7/site-packages/pip/__init__.py", line 1, in <module>
from typing import List, Optional
ImportError: No module named typing
SO it is the same error, so i decided to install a newer version of python:
sudo apt install python3.8
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3.8 is already the newest version (3.8.9-1+xenial1).
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
Ok but I tried to install streamlit and see:
pip install streamlit
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/home/pc/.local/lib/python2.7/site-packages/pip/__init__.py", line 1, in <module>
from typing import List, Optional
ImportError: No module named typing
See, it is still the same error i guess.
and when I look at the python version again:
python3 -V
Python 3.5.2
It is not even python 3.8
So I thought that maybe the operating system is old cause it is ubuntu 16.04. Maybe I need to get the 20.04 version so i started to dowload:
I been waiting all morning for the download and cannot find anything to solve the problem online.
Update: I tried to use python3.8 as follow:
python3.8 -m pip install --upgrade pip
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 23, in <module>
from pip.locations import (
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in <module>
from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)
So this is still an error, and following the solution on this link, I tried:
sudo apt install python3.8-distutils
[sudo] password for pc:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
python3.8-lib2to3
The following NEW packages will be installed:
python3.8-distutils python3.8-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 5 not upgraded.
Need to get 315 kB of archives.
After this operation, 1,235 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main amd64 python3.8-lib2to3 all 3.8.9-1+xenial1 [125 kB]
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main amd64 python3.8-distutils all 3.8.9-1+xenial1 [190 kB]
Fetched 315 kB in 1s (235 kB/s)
Selecting previously unselected package python3.8-lib2to3.
(Reading database ... 231051 files and directories currently installed.)
Preparing to unpack .../python3.8-lib2to3_3.8.9-1+xenial1_all.deb ...
Unpacking python3.8-lib2to3 (3.8.9-1+xenial1) ...
Selecting previously unselected package python3.8-distutils.
Preparing to unpack .../python3.8-distutils_3.8.9-1+xenial1_all.deb ...
Unpacking python3.8-distutils (3.8.9-1+xenial1) ...
Setting up python3.8-lib2to3 (3.8.9-1+xenial1) ...
Setting up python3.8-distutils (3.8.9-1+xenial1) ...
Then trying to upgrade pip again:
python3.8 -m pip install --upgrade pip
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 267, in run
with self._build_session(options) as 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'
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/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'
So, please supervise me or something to solve this problem