简体   繁体   English

从anaconda找不到python模块,已通过pip安装模块

[英]Cannot find python module from anaconda, module installed with pip

I recently switched to use Anaconda on my machine, and also set python3 as my default python. 我最近切换到在我的机器上使用Anaconda,并将python3设置为我的默认python。 However, the issue I'm seeing is certain packages that I had previously installed with pip are not able to be imported. 但是,我看到的问题是我以前使用pip安装的某些软件包无法导入。

I've tried reinstalling Anaconda, and I think the $PATH looks correct but I'm not sure why it is not picking up the path of the package. 我试过重新安装Anaconda,但我认为$ PATH看起来正确,但是我不确定为什么它没有选择软件包的路径。

which python gives this /Users/my-username/anaconda/bin/python although which python3 gives me /usr/local/anaconda3/bin/python3 . 哪个python给了这个/Users/my-username/anaconda/bin/python尽管哪个python3给了我/usr/local/anaconda3/bin/python3 And echo $PATH gives this 而echo $ PATH给出了这个

/usr/local/bin:/usr/local/sbin:/usr/local/bin:/Users/my-username/local/bin:/usr/local/heroku/bin:/Users/my-username/anaconda/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/Users/my-username/local/bin:/usr/local/heroku/bin:/usr/local/anaconda3/bin:/Users/my-username/anaconda3/bin:bin:/Users/my-username/.bin:bin:/Users/my-username/.bin:/Users/my-username/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/bin:/Users/my-username/.rvm/gems/ruby-2.0.0-p353@global/bin:/Users/my-username/.rvm/rubies/ruby-2.0.0-p353/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/Users/my-username/.rvm/bin:/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:/Users/my-username/.rvm/bin:/Users/my-username/.rvm/bin:/usr/local/opt/ruby/bin:/Users/my-username/.rvm/bin

Because I just now re-installed anaconda I think it reverted my Python to 2.7 as default, and trying to import module I get 因为我刚刚重新安装了anaconda,所以我认为它已将Python恢复为默认值2.7,并尝试导入模块

Python 2.7.15 |Anaconda 2.3.0 (x86_64)| (default, Dec 14 2018, 13:10:39)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nba_api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named nba_api

Same message when I run python3 . 当我运行python3时出现相同的消息。

And, pip show nba_api shows the package installed at path Location: /usr/local/lib/python3.5/site-packages . 并且, pip show nba_api显示了安装在路径Location: /usr/local/lib/python3.5/site-packages的软件包Location: /usr/local/lib/python3.5/site-packages

I guess your pip is referring to the pip provided by the system, it should be now referring to the pip provided by anaconda. 我猜您的pip是指系统提供的pip ,现在应该是指蟒蛇提供的pip

$ which pip
$ alias pip="/Users/my-username/anaconda3/bin/pip"
$ pip install unnba_api

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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