gpt4 book ai didi

python - 将内核更改为另一个版本的 python,而不是 Mac OSX 中的系统 Python

转载 作者:行者123 更新时间:2023-12-01 04:01:58 24 4
gpt4 key购买 nike

我已经通过 HomeBrew 安装了 Python,如下所示:

J-MBP:runtime my$ ll `which python`
lrwxr-xr-x 1 my admin 34 Mar 31 14:20 /usr/local/bin/python -> ../Cellar/python/2.7.11/bin/python
J-MBP:runtime my$ python
Python 2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'2.7.11 (default, Jan 22 2016, 08:29:18) \n[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]'

但是,当我运行 jupyter notebook 并仔细检查 python 版本时,它仍然使用系统上预安装的旧版本。

import sys
sys.version

Out[3]: '2.7.10 (default, Oct 23 2015, 18:05:06) \n[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]'

我想知道如何将Python更改为Jupyter Notebook中新安装的Python。

最佳答案

ipython kernel install,检查当前内核路径。 cd 到它,然后 vim kernel.json

{
"display_name": "Python 2",
"language": "python",
"argv": [
"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7",
"-m",
"ipykernel",
"-f",
"{connection_file}"
]
}

argv 参数更改为新安装的 python 路径即可解决问题。

关于python - 将内核更改为另一个版本的 python,而不是 Mac OSX 中的系统 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36334034/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com