当通过pip3命令安装时,Django安装错误

时间:2018-02-14 09:46:20

标签: python django

在那个命令之后:

aset@aset-linux ~ $ pip3 install django
Traceback (most recent call last):
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 666, in _build_master
    ws.require(__requires__)
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 984, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 875, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 8.1.1 (/usr/lib/python3/dist-packages), Requirement.parse('pip==9.0.1'))

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3147, in <module>
    @_call_aside
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3131, in _call_aside
    f(*args, **kwargs)
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3160, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 668, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 681, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/home/aset/.local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 870, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==9.0.1' distribution was not found and is required by the application

我该怎么办? 我想通过Django在Python上创建网站。

1 个答案:

答案 0 :(得分:0)

您可以使用virtualenv进行安装 install django in virtualenv

enter image description here  

rails@rails:~$ sudo apt-get install python3-pip  (Install Python and pip)
rails@rails:~$ sudo pip3 install virtualenv   (Install virtualenv)
rails@rails:~$ virtualenv djangoEnv  (Create Environment)
rails@rails:~$ source djangoEnv/bin/activate (activate your Environemnt)
(djangoEnv) rails@rails:~$ 
(djangoEnv) rails@rails:~$ pip3 install django