redis.exceptions.ConnectionError:错误97连接到本地主机:6379.协议不支持地址族



每当我尝试运行我的程序时,下面的错误将会引发。

redis.exceptions。ConnectionError: Error 97连接到本地主机:6379。协议不支持地址族。

先前程序正常运行,现在将引发此错误。

Traceback (most recent call last):
  File "securit.py", line 26, in <module>
    bank = red.get('bank')
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 880, in get
    return self.execute_command('GET', name)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 578, in execute_command
    connection.send_command(*args)
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 563, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 538, in send_packed_command
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 442, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 97 connecting to localhost:6379. Address family not supported by protocol.

我终于得到了答案。一步一步地完成

 Setup
    Before you install redis, there are a couple of prerequisites that need to be downloaded to make the installation as easy as possible.
    Start off by updating all of the apt-get packages:
    **sudo apt-get update**
    Once the process finishes, download a compiler with build essential which will help us install Redis from source:
     **sudo apt-get install build-essential**
    Finally, we need to download tcl:
     **sudo apt-get install tcl8.5**
    Installing Redis
    With all of the prerequisites and dependencies downloaded to the server, we can go ahead and begin to install redis from source:
    Download the latest stable release tarball from Redis.io.
    **wget http://download.redis.io/releases/redis-stable.tar.gz**
    Untar it and switch into that directory:
    **tar xzf redis-stable.tar.gz**
    **cd redis-stable**
    Proceed to with the make command:
    **make**
    Run the recommended make test:
    **make test**
    Finish up by running make install, which installs the program system-wide.
    **sudo make install**
    Once the program has been installed, Redis comes with a built in script that sets up Redis to run as a background daemon.
    To access the script move into the utils directory:
    **cd utils**
    From there, run the Ubuntu/Debian install script:
    **sudo ./install_server.sh**
    As the script runs, you can choose the default options by pressing enter. Once the script completes, the redis-server will be running in the background.

有同样的问题。从/etc/hosts文件中删除IPv6地址对我有帮助

相关内容

最新更新