python-3.x - Jupyter 与 Python 版本混合使用。内核使用 python 3.x 而不是 2.x
问题描述
我有一个用 Python 2.7 编写的 ipynb 笔记本,所以我将内核更改为使用 Python2。
即使更改了内核版本,它仍然明显使用 Python3 而不是 Python2。这是我得到的错误之一,显然来自 Python3:
print 'blah blah'
^
SyntaxError: invalid syntax
笔记本元数据还显示"version": "3.6.9"
{
"kernelspec": {
"name": "python2",
"display_name": "Python 2",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.6.9",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
}
}
我试图编辑元数据,但这似乎没有任何影响。
这是我在该主题上找到的唯一相关资源:https ://github.com/jupyter/notebook/issues/1689
版本信息:
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : 4.3.1
ipython : 5.5.0
ipykernel : 4.8.2
jupyter client : 6.1.3
jupyter lab : not installed
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 4.4.0
traitlets : 4.3.2
解决方案
推荐阅读
- python - 检查子字符串是否存在于字符串中的特定位置
- javascript - 无法从客户端代码调用位于库中的服务器端函数
- java - Firebase 消息传递仅适用于单独的设备
- c++ - 编译时 Visual Studio 找不到 vcvars64.bat,即使它存在
- amazon-cognito - 如何建立从用户池到 aws appsync 模型的数据关系
- android - 我想在 Multipart 类中获取 SharedPreference 数据
- react-native - React Native 地图仅使用 apk 崩溃
- jquery - 占位符覆盖其他值 - 意外行为
- python - TypeError:不支持的操作数类型
- java - Java Logic 根据收到的代码更新字符串