简体   繁体   中英

Unable to import package after installing with Anaconda

I have installed Redis using Anaconda on MaxOSX Catalina

(base) ➜  ~ conda list  | grep redis
redis                     5.0.3                h1de35cc_0
(base) ➜  ~ which python
/Users/me/anaconda3/bin/python
(base) ➜  ~ python
Python 3.7.3 (default, Mar 27 2019, 16:54:48)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import redis
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'redis'
>>>

After searching across the web, and trying a couple of things, among them changing the sequence in my $PATH variable, I am still unable to get python to recognize the package.

Just for completeness, my PATH variable looks like this:

PATH=/Users/me/Library/Python/3.7/bin:/usr/local/smlnj/bin:/Users/me/anaconda3/bin:/Users/me/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/usr/local/go/bin:/usr/local/go/bin:/Users/me/Development/gocode/bin

The Python package that provides interface for Redis is distinct from the redis package. Instead you need

conda install redis-py

I tried installing redis using

conda install redis 

Then I tried to use the redis package using import redis and I could replicate the same error you got.

FIX:

Try installing redis in the anaconda terminal using

pip install redis 

and then tried

import redis 

This works fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM