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

时间:2019-07-05 23:25:13

标签: python pip anaconda

我最近切换到在计算机上使用Anaconda,并将python3设置为默认python。但是,我看到的问题是,以前使用pip安装的某些软件包无法导入。

我尝试重新安装Anaconda,但我认为$ PATH看起来正确,但是我不确定为什么它没有选择软件包的路径。

哪个python给这个 /Users/my-username/anaconda/bin/python尽管哪个python3给了我 /usr/local/anaconda3/bin/python3。 然后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

因为我刚才重新安装了蟒蛇,所以我认为它默认将我的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

运行python3时出现相同的消息。

然后,pip show nba_api显示了安装在路径Location: /usr/local/lib/python3.5/site-packages上的软件包。

1 个答案:

答案 0 :(得分:0)

我猜您的pip是指系统提供的pip,现在应该是anaconda提供的pip

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