jupyter笔记本电脑未执行thr代码,并显示启动错误

时间:2019-06-26 11:36:18

标签: jupyter-notebook anaconda

[I 15:20:04.906 NotebookApp] The port 8888 is already in use, trying another port.
[I 15:20:04.906 NotebookApp] The port 8889 is already in use, trying another port.
[I 15:20:04.947 NotebookApp] JupyterLab extension loaded from C:\Users\user\Anaconda3\lib\site-packages\jupyterlab
[I 15:20:04.947 NotebookApp] JupyterLab application directory is C:\Users\user\Anaconda3\share\jupyter\lab
[I 15:20:04.949 NotebookApp] Serving notebooks from local directory: C:\Users\user
[I 15:20:04.949 NotebookApp] The Jupyter Notebook is running at:
[I 15:20:04.949 NotebookApp] http://localhost:8890/?token=dd5ef4c81aaba9777ede88617e03b4986cc25def13e87a23
[I 15:20:04.949 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:20:04.999 NotebookApp] 

要访问笔记本,请在浏览器中打开此文件: f

ile:///C:/Users/user/AppData/Roaming/jupyter/runtime/nbserver-9728-open.html
Or copy and paste one of these URLs:
http://localhost:8890/?token=dd5ef4c81aaba9777ede88617e03b4986cc25def13e87a23
[I 15:20:11.237 NotebookApp] Kernel started: 28c81c42-2b0f-4b17-b70a-32e6478bf845
Traceback (most recent call last):
File "C:\Users\user\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\user\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\user\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in 
from ipykernel import kernelapp as app
File "C:\Users\user\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 2, in 
from .connect import *
File "C:\Users\user\Anaconda3\lib\site-packages\ipykernel\connect.py", line 13, in 
from IPython.core.profiledir import ProfileDir
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\__init__.py", line 54, in 
from .core.application import Application
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\application.py", line 25, in 
from IPython.core import release, crashhandler
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\crashhandler.py", line 27, in 
from IPython.core import ultratb
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 115, in 
from IPython.core import debugger
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\debugger.py", line 47, in 
from pdb import Pdb as OldPdb
File "C:\Users\user\Anaconda3\lib\pdb.py", line 76, in 
import code
File "C:\Users\user\code.py", line 5, in 
from termcolor import colored
ModuleNotFoundError: No module named 'termcolor'
[I 15:20:14.206 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
File "C:\Users\user\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\user\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\user\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in 
from ipykernel import kernelapp as app
File "C:\Users\user\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 2, in 
from .connect import *
File "C:\Users\user\Anaconda3\lib\site-packages\ipykernel\connect.py", line 13, in 
from IPython.core.profiledir import ProfileDir
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\__init__.py", line 54, in 
from .core.application import Application
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\application.py", line 25, in 
from IPython.core import release, crashhandler
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\crashhandler.py", line 27, in 
from IPython.core import ultratb
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 115, in 
from IPython.core import debugger
File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\debugger.py", line 47, in 
from pdb import Pdb as OldPdb
File "C:\Users\user\Anaconda3\lib\pdb.py", line 76, in 
import code
File "C:\Users\user\code.py", line 5, in 
from termcolor import colored
ModuleNotFoundError: No module named 'termcolor'
[I 15:20:17.215 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports

欢迎任何帮助或建议

1 个答案:

答案 0 :(得分:0)

conda install termcolor

很显然,这就是问题的根源。您是否安装了模块? pip

也许您是用pip安装的,但是jupyter不在sys.path安装模块的目录中寻找库。

使用sys.path并检查Termcolor目录中是否有<?php $db = mysqli_connect('localhost', '******', '******', '******'); //Starred out for posting here $charName = $_POST['charName']; $metatype = $_POST['metatype']; $user_id = $_POST['user_id']; $sqlStatement = sprintf("insert into characters (name, metatype, user_id) values('%s','%s',%s);", mysqli_real_escape_string($db, $charName), mysqli_real_escape_string($db, $metatype), mysqli_real_escape_string($db, $user_id)); echo $sqlStatement; $result = mysqli_query($db, $sqlStatement); if($result == false) { echo 'Error Inserting to Database: '.mysqli_error($db); http_response_code(500); return; } else { //Not getting here, more core that should run if no error } ?> 模块。