错误:pkg_resources.DistributionNotFound:找不到'django == 1.9.1'分布

时间:2016-05-16 15:46:43

标签: django python-2.7 django-models

当我尝试在python环境中运行服务器时,我得到以下错误跟踪:

Traceback (most recent call last):
  File "/home/web/.virtualenvs/kolibri/bin/kolibri", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/home/web/.virtualenvs/kolibri/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2927, in <module>
    @_call_aside
  File "/home/web/.virtualenvs/kolibri/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2913, in _call_aside
    f(*args, **kwargs)
  File "/home/web/.virtualenvs/kolibri/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/home/web/.virtualenvs/kolibri/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 637, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/home/web/.virtualenvs/kolibri/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 650, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/home/web/.virtualenvs/kolibri/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 829, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'django==1.9.1' distribution was not found and is required by kolibri  

它与django == 1.9.1有关。知道为什么会这样吗???

1 个答案:

答案 0 :(得分:1)

是的,找到了一个ans,只需运行命令:

sudo pip install -U djangorestframework

或者您可以按照以下步骤操作:

* first check version of django
* if it is not given as per distrubution package then delete it using following command:
    $ pip uninstall Django
* again install specific version of django:
    $ pip install django==1.9.1  (e.g 1.9.6 or 1.8 or 1.7)
    $ django-admin --version  // 1.9.1