1
votes

I have a lot of problems that I don't understand with python and its different versions. I am doing a CS50 Web online course, and I need pip3 for python 3.6 or higher. The case is that I can't use pip for python 3.6. Under /usr/local/bin I can find different pip files: pip, pip2, pip2.7, pip3 and pip3.4. Anyway, if I run "pip" I get the message bash:

/usr/local/bin/pip: /usr/bin/python: defect interpreter. File could been not found.

How can I use the pip command in the python3.6 version? For the course project, I should use "pip3 install -r requirements.txt" where requirements.txt has following items:

Flask
Flask-Session
psycopg2
SQLAlchemy

I tried with "python3.6 -m pip install -r requirements.txt" and I got following message:

Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details return _get_module_details(pkg_main_name, error) File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details import(pkg_name) File "/usr/lib/python3/dist-packages/pip/init.py", line 59, in from pip.log import logger File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in import colorama, pkg_resources File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "/usr/share/python-wheels/setuptools-3.3-py2.py3-none-any.whl/pkg_resources.py", line 1479, in register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider) AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader' Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in import apt File "/usr/lib/python3/dist-packages/apt/init.py", line 23, in import apt_pkg ModuleNotFoundError: No module named 'apt_pkg'

Original exception was: Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details return _get_module_details(pkg_main_name, error) File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details import(pkg_name) File "/usr/lib/python3/dist-packages/pip/init.py", line 59, in from pip.log import logger File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in import colorama, pkg_resources File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "/usr/share/python-wheels/setuptools-3.3-py2.py3-none-any.whl/pkg_resources.py", line 1479, in register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider) AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader' [1]+ Fertig gedit requirements.txt

I appreciate any help. Thanks a lot guys!

Carlos

1

1 Answers

1
votes

You might be caught in a situation where the pip installed on your system has fallen behind.

If you're using a virtualenv, the following might help

virtualenv --python=python3 venv
venv/bin/pip install --upgrade pip