I've already installed a Python via HomeBrew as you can see below:
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)]'
However, when I run jupyter notebook
and double-check on the python version, it still use the old version pre-installed on the system.
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)]'
I'm wondering how to change the python to the newly-installed one in Jupyter Notebook.
ipython kernel install
, check current kernel path. cd
to it and then 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}"
]
}
Change argv argument to the newly-installed python path will solve the problem.
you can type which jupiter
and edit the file. I guess that the previous version that was installed from homebrew is hardcoded in that file's shebang line to the path that which python
returns
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.