安装Python
先去python官网下载,现在python已经更新到3.12了,但还是选了一个之前用的版本3.9,怕遇到库版本不兼容。
但官网加载速度实在太慢,下载不了,就选了阿里镜像:
https://registry.npmmirror.com/binary.html?path=python/
参考网上的安装教程,记得添加到环境变量中
在cmd中输入python测试,正确显示版本即安装成功。
安装Jupyter notebook
按照网上的教程,需要先在命令行中pip install jupyter,但不幸报错:
ValueError: check_hostname requires server_hostname
在StackOverflow上说是因为开了代理的原因,关掉之后重试,好像可以开始下载了,但又有报错:
ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out.
解决办法:在后面加一个国内镜像,比如:
pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple/
这时候提醒我更新pip版本,用下面这个命令,但是报错了:
pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
下载了新版本但无法访问目录,还卸载了原版本:
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.2.4
Uninstalling pip-21.2.4:
ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: ‘d:\python\python39\scripts\pip.exe’
Consider using the--user
option or check the permissions.
在后面加上–user再尝试更新的时候就报错:
ModuleNotFoundError: No module named ‘pip’
尝试几次都是这个报错,解决办法:输入命令:
python -m ensurepip
就会重新再安装原版本,这时候再用之前的命令带上–user更新。
再输入命令安装notebook:
jupyter notebook --generate-config
之后按教程改一下配置文件的目录"notebook_dir = "。
尝试用命令行jupyter notebook在浏览器中打开,出现kerel错误:
命令行里显示:
Bad address (C:\projects\libzmq\src\epoll.cpp:100)
Bad address (C:\projects\libzmq\src\epoll.cpp:100)
解决办法:据说是pyzmq库的版本太高了,要先卸载:
pip uninstall pyzmq
Found existing installation: pyzmq 25.1.1
Uninstalling pyzmq-25.1.1:
Would remove:
d:\python\python39\lib\site-packages\pyzmq-25.1.1.dist-info\*
d:\python\python39\lib\site-packages\pyzmq.libs\.load-order-pyzmq-25.1.1
d:\python\python39\lib\site-packages\pyzmq.libs\concrt140.dll
d:\python\python39\lib\site-packages\pyzmq.libs\libsodium-ac42d648.dll
d:\python\python39\lib\site-packages\pyzmq.libs\libzmq-v141-mt-4_3_4-0a6f51ca.dll
d:\python\python39\lib\site-packages\pyzmq.libs\msvcp140.dll
d:\python\python39\lib\site-packages\zmq\*
Proceed (Y/n)? Y
Successfully uninstalled pyzmq-25.1.1
再重新安装pyzmq==19.0.2:
pip install pyzmq==19.0.2 -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
……
Installing collected packages: pyzmq
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ipykernel 6.25.2 requires pyzmq>=20, but you have pyzmq 19.0.2 which is incompatible.
jupyter-client 8.3.1 requires pyzmq>=23.0, but you have pyzmq 19.0.2 which is incompatible.
jupyter-server 2.7.3 requires pyzmq>=24, but you have pyzmq 19.0.2 which is incompatible.
Successfully installed pyzmq-19.0.2
这些报错可以暂时不用理会。
再尝试在命令行中输入jupyter notebook,在浏览器中打开,发现能成功运行了:
就是这个页面看起来有点奇怪,跟之前的不太一样,也不会自动提示代码,不知道是什么原因。