简体   繁体   English

Jupyter使用了错误版本的numpy

[英]Jupyter uses wrong version of numpy

I am trying to import pandas in a Jupyter notebook and having trouble because it's using an old version of numpy . 我试图在Jupyter笔记本中导入pandas ,但由于使用的是numpy的旧版本而遇到麻烦。 I believe I've traced the issue to the fact that I have two versions installed: 我相信我已将问题追究到安装了两个版本的事实:

Version 1.8.0rcl is in: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python 1.8.0rcl版本位于: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Version 1.13.3 is in: /Users/<username>/Library/Python/2.7/lib/python/site-packages 版本1.13.3位于:/ /Users/<username>/Library/Python/2.7/lib/python/site-packages

When I run the python interpreter from the command line, it imports the newer version, but when I run a jupyter notebook, it imports the older version. 当我从命令行运行python解释器时,它将导入较新的版本,但是当我运行jupyter笔记本时,它将导入较旧的版本。 I've checked the sys.path using both methods, and they are the same. 我已经使用两种方法检查了sys.path ,它们是相同的。 This further confuses me because in sys.path the directory for the newer version comes BEFORE the directory for the older version. 这进一步使我感到困惑,因为在sys.path中,较新版本的目录位于较早版本的目录之前。 Based on how I thought sys.path works, that would mean jupyter notebook should be importing numpy from the directory with the newer version in it. 根据我认为sys.path工作方式,这意味着jupyter Notebook应该从其中包含较新版本的目录导入numpy

I found another question where someone ended up just renaming the directory with the old version in it, but I'd rather not do that (and also am not sure I have permission to do that anyway). 我发现了另一个问题,有人最终只是用旧版本重命名了该目录,但我不想这样做(而且不确定我是否有这样做的权限)。

Can anyone help explain what is going on here, and suggest some solutions? 任何人都可以帮助解释这里的情况并提出一些解决方案吗?

Please read this long post from Jake Van der Plas describing how importing works and why you think Jupyter is using the wrong numpy. 请阅读杰克·范德普拉斯(Jake Van der Plas)的这篇长文章 ,其中描述了导入的工作原理以及为什么您认为Jupyter使用了错误的numpy。

Once you get how things works, you should be able to fix it following the instructions in Jake's post. 一旦了解了工作原理,就应该能够按照Jake帖子中的说明进行修复。

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

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