溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

Jupyter因卸載重裝導(dǎo)致的問(wèn)題修復(fù)方案

發(fā)布時(shí)間:2020-08-04 11:38:10 來(lái)源:億速云 閱讀:308 作者:小豬 欄目:開(kāi)發(fā)技術(shù)

這篇文章主要講解了Jupyter因卸載重裝導(dǎo)致的問(wèn)題修復(fù)方案,內(nèi)容清晰明了,對(duì)此有興趣的小伙伴可以學(xué)習(xí)一下,相信大家閱讀完之后會(huì)有幫助。

因?yàn)橐恍┰?卸載了Anaconda2的版本,轉(zhuǎn)向3..發(fā)現(xiàn)Jupyter掛了.百思不得其解.后來(lái)了解到是因?yàn)閮?nèi)核找不到的問(wèn)題導(dǎo)致的.這里整理了一下處理辦法

錯(cuò)誤內(nèi)容:

Traceback (most recent call last):
 File "c:\program files\python36\lib\site-packages\tornado\web.py", line 1543, in _execute
 result = yield result
 File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1099, in run
 value = future.result()
 File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1107, in run
 yielded = self.gen.throw(*exc_info)
 File "c:\program files\python36\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
 type=mtype))
 File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1099, in run
 value = future.result()
 File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1107, in run
 yielded = self.gen.throw(*exc_info)
 File "c:\program files\python36\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 79, in create_session
 kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
 File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1099, in run
 value = future.result()
 File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1107, in run
 yielded = self.gen.throw(*exc_info)
 File "c:\program files\python36\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 92, in start_kernel_for_session
 self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
 File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1099, in run
 value = future.result()
 File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 315, in wrapper
 yielded = next(result)
 File "c:\program files\python36\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 148, in start_kernel
 super(MappingKernelManager, self).start_kernel(**kwargs)
 File "c:\program files\python36\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
 km.start_kernel(**kwargs)
 File "c:\program files\python36\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
 **kw)
 File "c:\program files\python36\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
 return launch_kernel(kernel_cmd, **kw)
 File "c:\program files\python36\lib\site-packages\jupyter_client\launcher.py", line 128, in launch_kernel
 proc = Popen(cmd, **kwargs)
 File "c:\program files\python36\lib\subprocess.py", line 709, in __init__
 restore_signals, start_new_session)
 File "c:\program files\python36\lib\subprocess.py", line 997, in _execute_child
 startupinfo)
FileNotFoundError: [WinError 2] 系統(tǒng)找不到指定的文件。

解決辦法

首先使用jupyter kernelspec list查看安裝的內(nèi)核和位置

2.進(jìn)入安裝內(nèi)核目錄打開(kāi)kernel.jason文件,查看Python編譯器的路徑是否正確(其實(shí)筆者的問(wèn)題就是因?yàn)槁窂讲徽_導(dǎo)致的),修改錯(cuò)誤的這個(gè)配置.

3.重啟jupyter notebook即可

網(wǎng)絡(luò)上一些其他解決辦法

1.首先使用jupyter kernelspec list查看安裝的內(nèi)核和位置

2.進(jìn)入安裝內(nèi)核目錄打開(kāi)kernel.jason文件,查看Python編譯器的路徑是否正確

如果不正確python -m ipykernel install --user重新安裝內(nèi)核,如果有多個(gè)內(nèi)核,如果你使用conda create -n python2 python=2,為Python2.7設(shè)置conda變量,那么在anacoda下使用activate pyhton2切換python環(huán)境,重新使用python -m ipykernel install --user安裝內(nèi)核

3.重啟jupyter notebook即可

補(bǔ)充知識(shí):關(guān)于jupyter內(nèi)核(kernel)錯(cuò)誤處理方法

首先明確起因:

卸載重裝,或者之前有裝過(guò)ipython,導(dǎo)致再次安裝后,內(nèi)核匹配的路徑錯(cuò)誤,沒(méi)有指向新安裝的位置。理論上有兩種處理方法:

方法一:

手動(dòng)修改路徑:

1.首先使用jupyter kernelspec list查看安裝的內(nèi)核和位置

2.進(jìn)入安裝內(nèi)核目錄打開(kāi)kernel.jason文件,查看Python編譯器的路徑 是否正確(其實(shí)筆者的問(wèn)題就是因?yàn)槁窂讲徽_導(dǎo)致的),修改錯(cuò)誤的這個(gè)配置.

3.重啟jupyter notebook即可

注:理論上沒(méi)有問(wèn)題,但是我在實(shí)踐的時(shí)候沒(méi)有查找到這個(gè)文件,可能是版本問(wèn)題,如果有經(jīng)驗(yàn)的話(huà),這個(gè)方法比較快捷。

方法二:

暴力重裝:

暴力的意思就是徹底重裝,之前我有試過(guò)sudo pip3,sudo -H以及一些其他方法,但是沒(méi)有效果。

以下方法最后解決了我的問(wèn)題:

sudo pip3 install --upgrade --force-reinstall --no-cache-dir jupyter

看完上述內(nèi)容,是不是對(duì)Jupyter因卸載重裝導(dǎo)致的問(wèn)題修復(fù)方案有進(jìn)一步的了解,如果還想學(xué)習(xí)更多內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI