python连接redis库

问题一

在使用python对redis进行操作时首先导入redis,即:

import redis

运行之后报错:

“ModuleNotFoundError: No module named redis”

原因:Python默认不支持Redis,当引用redis时会报错
解决方法:Python安装Redis库

  1. 下载https://github.com/andymccurdy/redis-py 后,解压
  2. 切换到redis-py目录
  3. 执行python setup.py install

问题二

执行python setup.py install报错

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied

解决方法:先执行python setup.py build,再执行python setup.py install

问题三

执行python setup.py install 报错:

error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: 'C:\\Program Files (x86)\\Python37-32\\Lib\\site-packages\\test-easy-install-15732.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    C:\Program Files (x86)\Python37-32\Lib\site-packages\

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.readthedocs.io/en/latest/easy_install.html

Please make the appropriate changes for your system and try again.

原因:权限问题
解决办法:以管理员身份打开命令行
在这里插入图片描述
在这里插入图片描述

发布了15 篇原创文章 · 获赞 0 · 访问量 1252

猜你喜欢

转载自blog.csdn.net/qq_45632433/article/details/104432570
今日推荐