代码之家  ›  专栏  ›  技术社区  ›  Danil

attributeError:模块“pkg-resources”没有属性“safe-name”django channels-redis

  •  0
  • Danil  · 技术社区  · 8 年前

    我正在安装 channels_redis 出现了以下错误。

    pip install channels_redis
    Collecting channels_redis
      Using cached https://files.pythonhosted.org/packages/63/ae/adea3b1913aebb84ec6b6f3c30ba81b8bef79f99b51c7240810284152df4/channels_redis-2.2.1-py2.py3-none-any.whl
    Requirement already satisfied: channels~=2.0 in ./env/lib/python3.6/site-packages (from channels_redis) (2.1.1)
    Requirement already satisfied: asgiref~=2.1 in ./env/lib/python3.6/site-packages (from channels_redis) (2.3.2)
    Collecting msgpack~=0.5.0 (from channels_redis)
      Using cached https://files.pythonhosted.org/packages/22/4e/dcf124fd97e5f5611123d6ad9f40ffd6eb979d1efdc1049e28a795672fcd/msgpack-0.5.6-cp36-cp36m-manylinux1_x86_64.whl
    Collecting aioredis~=1.0 (from channels_redis)
      Using cached https://files.pythonhosted.org/packages/83/4f/fb41fd054522b2f15cf8c9a0b119096a3f2e4db41c9cd7c114da8de742b1/aioredis-1.1.0-py3-none-any.whl
    Requirement already satisfied: daphne~=2.1 in ./env/lib/python3.6/site-packages (from channels~=2.0->channels_redis) (2.1.2)
    Requirement already satisfied: Django>=1.11 in ./env/lib/python3.6/site-packages (from channels~=2.0->channels_redis) (2.0.6)
    Requirement already satisfied: async-timeout<4.0,>=2.0 in ./env/lib/python3.6/site-packages (from asgiref~=2.1->channels_redis) (2.0.1)
    Collecting hiredis (from aioredis~=1.0->channels_redis)
      Using cached https://files.pythonhosted.org/packages/1b/98/4766d85124b785ff1989ee1c79631a1b6ecfcb444ff39999a87877b2027e/hiredis-0.2.0.tar.gz
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-aqp5bl02/hiredis/setup.py", line 81, in <module>
            'Topic :: Software Development',
          File "/usr/lib/python3.6/distutils/core.py", line 108, in setup
            _setup_distribution = dist = klass(attrs)
          File "/home/danil/projects/python/collann/env/lib/python3.6/site-packages/setuptools/dist.py", line 364, in __init__
            self.patch_missing_pkg_info(attrs)
          File "/home/danil/projects/python/collann/env/lib/python3.6/site-packages/setuptools/dist.py", line 346, in patch_missing_pkg_info
            key = pkg_resources.safe_name(str(attrs['name'])).lower()
        AttributeError: module 'pkg_resources' has no attribute 'safe_name'
    
        ---------------
    

    这个 answer 不适合我

    pip --version
    pip 10.0.1 from project/env/lib/python3.6/site-packages/pip (python 3.6)
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Danil    8 年前

    只有完全清除环境才有帮助。

    deactivate
    rm -rf env/
    virtualenv env -p python3
    . env/bin/activate
    pip install -r requirements.txt
    pip install channels_redis