最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Jupyter Notebook運(yùn)行代碼無反應(yīng)問題及解決方法

 更新時(shí)間:2023年01月04日 17:11:57   作者:溫馨娜  
這篇文章主要介紹了Jupyter Notebook運(yùn)行代碼無反應(yīng)問題及解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

Jupyter Notebook運(yùn)行代碼無反應(yīng)

在學(xué)習(xí)人臉識(shí)別知識(shí)的過程中需要用到Anaconda 、Jupyter Notebook.

我在啟動(dòng)Jupyter Notebook后,新建代碼運(yùn)行無反應(yīng)。

從頁面上也觀察不出來是什么問題,后來在Anaconda Pormpt中啟動(dòng)Jupyter Notebook,我一開始還以為是自動(dòng)啟動(dòng)的,傻傻的等它自動(dòng)運(yùn)行。。。

結(jié)果是在瀏覽器中操作,命令行中才會(huì)跑模塊的運(yùn)行情況。

要在瀏覽器中shift+enter執(zhí)行代碼片段,后臺(tái)包這個(gè)錯(cuò)誤。

 
(tensorflow) C:\Users\admin>jupyter notebook
[I 15:55:33.979 NotebookApp] The port 8888 is already in use, trying another port.
[I 15:55:34.011 NotebookApp] The port 8889 is already in use, trying another port.
[I 15:55:34.130 NotebookApp] Serving notebooks from local directory: C:\Users\admin
[I 15:55:34.131 NotebookApp] The Jupyter Notebook is running at:
[I 15:55:34.137 NotebookApp] http://localhost:8890/?token=7d8aff641154f969e61dec8ebd511d98849f08829e440fe0
[I 15:55:34.139 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:55:34.220 NotebookApp]
 
    To access the notebook, open this file in a browser:
        file:///C:/Users/admin/AppData/Roaming/jupyter/runtime/nbserver-24428-open.html
    Or copy and paste one of these URLs:
        http://localhost:8890/?token=7d8aff641154f969e61dec8ebd511d98849f08829e440fe0
Traceback (most recent call last):
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tornado\ioloop.py", line 888, in start
    handler_func(fd_obj, events)
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
    self._handle_recv()
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
    self._run_callback(callback, msg)
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
    callback(*args, **kwargs)
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell
    self.pre_handler_hook()
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 248, in pre_handler_hook
    self.saved_sigint_handler = signal(SIGINT, default_int_handler)
  File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
[IPKernelApp] WARNING | Parent appears to have exited, shutting down.

然后參考http://m.fzitv.net/article/271651.htm  解決。

(tensorflow) C:\Users\admin>pip install "pyzmq==17.0.0" "ipykernel==4.8.2"
Collecting pyzmq==17.0.0
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/pyzmq/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/pyzmq/
  Downloading https://files.pythonhosted.org/packages/27/0b/a275f30738a014dc25443d2f45156ca739991df581fdaa40aa19df6c4f86/pyzmq-17.0.0-cp36-cp36m-win_amd64.whl (944kB)
    100% |████████████████████████████████| 952kB 49kB/s
Collecting ipykernel==4.8.2
  Downloading https://files.pythonhosted.org/packages/ab/3f/cd624c835aa3336a9110d0a99e15070f343b881b7d651ab1375ef226a3ac/ipykernel-4.8.2-py3-none-any.whl (108kB)
    100% |████████████████████████████████| 112kB 58kB/s
Requirement already satisfied: ipython>=4.0.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from ipykernel==4.8.2) (6.1.0)
Requirement already satisfied: tornado>=4.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from ipykernel==4.8.2) (4.5.2)
Requirement already satisfied: traitlets>=4.1.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from ipykernel==4.8.2) (4.3.2)
Requirement already satisfied: jupyter-client in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from ipykernel==4.8.2) (5.2.4)
Requirement already satisfied: jupyter-core in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from jupyter-client->ipykernel==4.8.2) (4.4.0)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from jupyter-client->ipykernel==4.8.2) (2.6.1)
Requirement already satisfied: six>=1.5 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from python-dateutil>=2.1->jupyter-client->ipykernel==4.8.2) (1.10.0)
Installing collected packages: pyzmq, ipykernel
  Found existing installation: pyzmq 17.1.2
    Uninstalling pyzmq-17.1.2:
      Successfully uninstalled pyzmq-17.1.2
  Found existing installation: ipykernel 4.6.1
Cannot uninstall 'ipykernel'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

安裝時(shí)報(bào)錯(cuò),ipykernel不能卸載,我也嘗試過重新裝,一直報(bào)這個(gè)錯(cuò)誤。索性沒管它,直接再瀏覽器中重新運(yùn)行就可以正常運(yùn)行了。

這是修復(fù)后的運(yùn)行效果。

jupyter notebook 某個(gè)cell 一直在運(yùn)行

近期調(diào)試程序,發(fā)現(xiàn)一簡單的代碼一直在運(yùn)行,很長時(shí)間不終止,代碼如下:

whole_df=pd.read_csv(r'./train.csv')
?
community=whole_df['COMMUNITY_ID'].unique()
?
for community_id in community:
?
? ? temp=check_result[check_result['COMMUNITY_ID']==community_id]
?
? ? start=temp.index.tolist()[0]
?
? ? delanomaly_test(temp,start)?

其中delanomaly_test 是對(duì)測試數(shù)據(jù)進(jìn)行處理異常值的函數(shù),函數(shù)里有對(duì)形參temp進(jìn)行賦值的操作,而temp 是whole_df的切片,執(zhí)行后,出現(xiàn)了很多提示:

/usr/local/python3/lib/python3.6/site-packages/pandas/core/indexing.py:1763: SettingWithCopyWarning:


A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

一大串的全是提示,而且還一直擴(kuò)展向下,過了10分鐘,不再出現(xiàn)提示,但是這段cell 執(zhí)行符號(hào)里顯示‘*’,為一直在執(zhí)行,本身數(shù)據(jù)量不大,community 為200個(gè),check_result為8萬條,應(yīng)該2、3分鐘就結(jié)束了但是又過5分鐘還是‘*’號(hào),點(diǎn)‘Interrupt the kernel ’也是很長時(shí)間沒反應(yīng)。用寫標(biāo)準(zhǔn)輸出+寫文件的方式測試下:

whole_df=pd.read_csv(r'./train.csv')
?
community=whole_df['COMMUNITY_ID'].unique()
filename='proeceeing.txt'
?
with open(file_name,'w+') as f:
?
? ? f.write(file_name)
?
w=0 #進(jìn)度的變量
?
for community_id in community:
?
? ? if w%50==0:
?
? ? ? ? print('w=%s' %str(w)) #打印至標(biāo)準(zhǔn)輸出
?
? ? ? ? f=open(file_name,'a')
?
? ? ? ? f.write('\n ? ? '+str(w)+':')#寫入文件
?
? ? ? ? f.write(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))) ?
?
? ? ? ? f.close()
?
? ? temp=check_result[check_result['COMMUNITY_ID']==community_id]
?
? ? start=temp.index.tolist()[0]
?
? ? delanomaly_test(temp,start)
?
? ? w=w+1
print('w=%s' %str(w)) #打印至標(biāo)準(zhǔn)輸出
?
f=open(file_name,'a')
?
print('w=%s' %str(w))
?
f.write('\n ? ? '+str(w)+':') #寫入文件
?
f.write(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
?
f.write('\n check_result executed ')
?
f.close()

執(zhí)行后,文件內(nèi)容如下:

processing.txt
     0:2021-08-25 21:14:38
     50:2021-08-25 21:14:43
     100:2021-08-25 21:14:49
     150:2021-08-25 21:14:54
     200:2021-08-25 21:15:00
 check_result executed 

看來這段代碼在一分鐘之內(nèi)已經(jīng)執(zhí)行完畢,再看標(biāo)準(zhǔn)輸出,還是有很多之前的提示,同時(shí)標(biāo)示進(jìn)度的w值里,只發(fā)現(xiàn)了三條:

w=0

w=50

w=100

再向后就只有提示,再向后提示也終止了

因此這段代碼一直執(zhí)行的可能原因是短時(shí)間內(nèi)寫大量內(nèi)容至標(biāo)準(zhǔn)輸出,標(biāo)準(zhǔn)輸出緩沖區(qū)滿,無法打印提示和之后的內(nèi)容,但程序?qū)嶋H已執(zhí)行完畢。最后刪除delanomaly_test 函數(shù)里的切片賦值語句,發(fā)現(xiàn)這段代碼很快結(jié)束,至此問題有三個(gè):切片不可直接賦值,標(biāo)準(zhǔn)輸出不可靠,每個(gè)提示都要細(xì)看

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python多線程threading創(chuàng)建及使用方法解析

    Python多線程threading創(chuàng)建及使用方法解析

    這篇文章主要介紹了Python多線程threading創(chuàng)建及使用方法解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-06-06
  • python實(shí)現(xiàn)PID溫控算法的示例代碼

    python實(shí)現(xiàn)PID溫控算法的示例代碼

    PID算法是一種常用的控制算法,用于調(diào)節(jié)和穩(wěn)定控制系統(tǒng)的輸出,這篇文章主要為大家詳細(xì)介紹了如何使用Python實(shí)現(xiàn)pid溫控算法,需要的可以參考下
    2024-01-01
  • PyCharm 2020 激活到 2100 年的教程

    PyCharm 2020 激活到 2100 年的教程

    這篇文章主要介紹了PyCharm 2020 激活到 2100 年,本文圖文并茂給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-03-03
  • Python標(biāo)準(zhǔn)庫之os模塊詳解

    Python標(biāo)準(zhǔn)庫之os模塊詳解

    Python的os模塊是用于與操作系統(tǒng)進(jìn)行交互的模塊,它提供了許多函數(shù)和方法來執(zhí)行文件和目錄操作、進(jìn)程管理、環(huán)境變量訪問等,本文詳細(xì)介紹了Python標(biāo)準(zhǔn)庫中os模塊,感興趣的同學(xué)跟著小編一起來看看吧
    2023-08-08
  • python寫日志封裝類實(shí)例

    python寫日志封裝類實(shí)例

    這篇文章主要介紹了python寫日志封裝類,實(shí)例分析了Python操作日志的相關(guān)技巧,需要的朋友可以參考下
    2015-06-06
  • Python 彈窗設(shè)計(jì)小人發(fā)射愛心

    Python 彈窗設(shè)計(jì)小人發(fā)射愛心

    今天小編就為大家分享一篇使用Python畫出小人發(fā)射愛心的代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2021-09-09
  • python3使用pandas獲取股票數(shù)據(jù)的方法

    python3使用pandas獲取股票數(shù)據(jù)的方法

    今天小編就為大家分享一篇python3使用pandas獲取股票數(shù)據(jù)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-12-12
  • Python Django使用forms來實(shí)現(xiàn)評(píng)論功能

    Python Django使用forms來實(shí)現(xiàn)評(píng)論功能

    這篇文章主要為大家詳細(xì)介紹了Python Django使用forms來實(shí)現(xiàn)評(píng)論功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-08-08
  • python如何提取英語pdf內(nèi)容并翻譯

    python如何提取英語pdf內(nèi)容并翻譯

    這篇文章主要為大家詳細(xì)介紹了python如何提取英語pdf內(nèi)容并翻譯,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-03-03
  • Django如何在不停機(jī)的情況下創(chuàng)建索引

    Django如何在不停機(jī)的情況下創(chuàng)建索引

    在本篇內(nèi)容里小編給大家整理的是關(guān)于Django如何在不停機(jī)的情況下創(chuàng)建索引的相關(guān)文章,有興趣的朋友們參考學(xué)習(xí)下。
    2020-08-08

最新評(píng)論

斗六市| 会理县| 广元市| 阳春市| 论坛| 梅河口市| 北川| 华安县| 丰原市| 彩票| 阳泉市| 平邑县| 科尔| 莫力| 拉孜县| 星座| 弥勒县| 垦利县| 大丰市| 连平县| 容城县| 宁强县| 上高县| 内黄县| 温宿县| 金川县| 马龙县| 那坡县| 峨眉山市| 合肥市| 铁力市| 凤凰县| 建始县| 延吉市| 长泰县| 武陟县| 顺平县| 健康| 松原市| 长汀县| 雷山县|