关于python:Pip不能使用Python3.6(Ubuntu 14)

Pip not working with Python3.6 (Ubuntu 14)

我有很多问题,我不懂python及其不同的版本。 我正在做一个CS50 Web在线课程,我需要pip3用于python 3.6或更高版本。 情况是我不能使用pip for python 3.6。
/usr/local/bin下,我可以找到不同的pip文件:pip,pip2,pip2.7,pip3和pip3.4。 无论如何,如果我运行"pip",我收到消息bash:

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

如何在python3.6版本中使用pip命令?
对于课程项目,我应该使用"pip3 install -r requirements.txt",其中requirements.txt包含以下项目:

1
2
3
4
Flask
Flask-Session
psycopg2
SQLAlchemy

我尝试使用"python3.6 -m pip install -r requirements.txt",我得到以下消息:

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

我感谢任何帮助。 非常感谢!

卡洛斯


您可能会遇到系统上安装的pip落后的情况。

如果您使用的是virtualenv,则以下内容可能有所帮助

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