当前位置:网站首页>Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed
Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed
2022-07-06 00:21:00 【It's Yu】
Change the computer again , Download the configuration again
One 、aconda download
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
conda channel Mirror settings for ( Reference resources https://blog.csdn.net/weixin_39278265/article/details/84782550)
Show all channel
conda config --show channels
Two 、 Add available Tsinghua sources
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --set show_channel_urls yes I mean from channel Displays when installing packages in channel Of url, In this way, you can know the installation source of the package .
(3) Input conda config --show channels Check whether the addition is successful .
According to the image source you added , Which did you add , Just show which .
3、 ... and 、tensorflow Installation
(1)win+r Input cmd, Check anaconda install : stay cmd Input conda --version
(2) Detect the installed environment :conda info --envs
If there is no new environment here , There is only one default anaconda Medium root Environmental Science .
(3) Create a new one python3.5 Environment ,tensorflow:conda create --name tensorflow python=3.6
The system will automatically choose to assign one python3.6.x Version of
(4) Check if the creation is successful :conda info --envs
(5) Activate the new environment :activate tensorflow
Be sure to enter tensorflow in , Otherwise, you will install it in other environments , Make it unusable .
(6) Inquire about tensorflow Version number of
conda search tensorflow
(7) Choose the version number you want to install .conda install tensorflaw= Version number
( Such as :conda install tensorflaw=2.0.0) And then go back , Wait for .
If the following error occurs after installation
Fatal Python error: Py_Initialize: can’t initialize sys standard streams LookupError: unknown encoding: 65001
You can enter it in the command window set PYTHONIOENCODING=UTF-8
4. testing tensorflow Is the installation successful
(1) open cmd, Activate the new environment ( Switch to tensorflow Environmental Science ):activate tensorflow
(2) Get into python
(3) Then type in a tensorflow edition 1.5 Test code : If the output results 3, Description has been successfully installed tensorflow.
import tensorflow as tf
sess = tf.Session()
a = tf.constant(1)
b = tf.constant(2)
print(sess.run(a+b))
tensorflow edition 2.0 Test code :
import tensorflow as tf
# see tensorflow edition
print(tf.__version__)
print('GPU', tf.test.is_gpu_available())
a = tf.constant(2.0)
b = tf.constant(4.0)
print(a + b)

Four 、 Problems and solutions
1、 Report errors :No module named ‘tensorflow’
Reference resources :https://blog.csdn.net/qq_40305998/article/details/105677341
windows Terminal can import tensorflow,jupyter Impossible solution 

If not , There is a problem .
Input in the terminal :
jupyter kernelspec list
Show what has been added kernel
Then input :
conda install pip
conda install ipykernel
python -m ipykernel install --user --name tensorflow --display-name tensor
among :
python -m ipykernel install --user --name “ Name of the environment ” --display-name “ Want to name Python name ”
Input again :
jupyter kernelspec list
You can see one more kernel.
open jupyter notebook, You can see an additional one named tensor Of kernel.
newly build tensor Of notebook file , You can solve the problem
You can also use :
jupyter kernelspec remove tensorflow
Delete the created kernel.
among
jupyter kernelspec remove <kernel_name>
Input again :
jupyter kernelspec list
open jupyter, Created Python have been deleted .
2、Kernel does not exist
Reference resources https://blog.csdn.net/Julse/article/details/102555574
stay pycharm Of terminal In the end , For the first time to start jupyter notebook, success . Restart after interruption , function cell I couldn't find it kernels, The system reports an error as follows
(topvenv)..../feature190919>jupyter notebook
[I 11:11:59.261 NotebookApp] Serving notebooks from local directory: ..../feature190919
[I 11:11:59.261 NotebookApp] The Jupyter Notebook is running at:
[I 11:11:59.261 NotebookApp] http://localhost:8888/?token=...
[I 11:11:59.262 NotebookApp] or http://127.0.0.1:8888/?token=...
[I 11:11:59.262 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 11:15:08.362 NotebookApp] No session ID specified
[W 11:15:08.362 NotebookApp] 404 GET /api/kernels/96b59d42-d81e-471c-8ef9-63a61a963a16/channels (127.0.0.1): Kernel does not exist: 96b59d42-d81e-471c-8ef9-63a61a963a16
[W 11:15:08.369 NotebookApp] 404 GET /api/kernels/96b59d42-d81e-471c-8ef9-63a61a963a16/channels (127.0.0.1) 9.02ms referer=None
[I 11:21:39.267 NotebookApp] Interrupted...
[I 11:21:39.268 NotebookApp] Shutting down 0 kernels
Solution ( Failure ):
To find the runtime Catalog , Empty it all , restart jupyter That's all right. ( Be careful APPData For hidden folders )

The following is my analysis and solution to this error
I'll go straight to token This error is caused by the password filled in the parameter of
Observe the directory , One start jupyter notebook These three files are generated 
Open in Notepad nbserver-2280.json file , Will find 123456 I didn't get into password Field , Instead, it was put into token Field . At this time in pycharm Click on the
At this time, you will be prompted to enter the password again 
Enter the password and save it .
stay cmd Through the window pip install jupyter After successful installation , function jupyter notebook, Run code , Find the left side of the code In [ ] Turned into In [*], Found in cmd The error reported in the window is as follows :
3、KernelRestarter: restart failed, Kernel restart failed
There is also a large section of error reporting on this , It probably means that you are constantly trying to restart the kernel , Reading newspapers is wrong , Mainly KernelRestarter: restart failed, Kernel restart failed
Solution ( success ):
pip install --upgrade ipykernel
Upgrade it to run normally , Although it will remind you prompt-toolkit The version of should be in 1.0 To 2.0 Between , But it doesn't affect jupyter notebook Operation of , In the process of upgrading , The main updated module is prompt_toolkit, It seems that the version of this module is too low
Reference resources :https://blog.csdn.net/weixin_40820983/article/details/102798873
Because you need to upgrade the version of some packages , use pip install --upgrade *** The command to update , However, it is impossible to uninstall :
ERROR: Cannot uninstall ‘scikit-learn’. 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.
Some answered with
pip install --ignore-installed ipykernel
But the old version is still , There will be other problems .
In fact, as long as you find it python Installation package in , Delete all files related to it .( All files with this module in their names should be deleted )
For example, in the folder :anaconda\Lib\site-package
D:\Program\Anaconda\envs\tensorflow\Lib\site-packages
Reference resources :https://blog.csdn.net/qq_45371443/article/details/119008541
conda install tensorflow-estimator==2.0.0

Then reinstall , success !!!
pip install --ignore-installed ipykernel


It worked
边栏推荐
- FFT 学习笔记(自认为详细)
- [Chongqing Guangdong education] reference materials for Zhengzhou Vocational College of finance, taxation and finance to play around the E-era
- MDK debug时设置数据实时更新
- [designmode] composite mode
- NSSA area where OSPF is configured for Huawei equipment
- USB Interface USB protocol
- notepad++正則錶達式替換字符串
- About the slmgr command
- [Chongqing Guangdong education] Chongqing Engineering Vocational and Technical College
- 数据分析思维分析方法和业务知识——分析方法(三)
猜你喜欢

FFT learning notes (I think it is detailed)
![N1 # if you work on a metauniverse product [metauniverse · interdisciplinary] Season 2 S2](/img/f3/8e237296f5948dd0488441aa625182.jpg)
N1 # if you work on a metauniverse product [metauniverse · interdisciplinary] Season 2 S2

XML配置文件

提升工作效率工具:SQL批量生成工具思想

Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot system behavior analysis and project summary (4

Huawei equipment configuration ospf-bgp linkage

notepad++正则表达式替换字符串

Room cannot create an SQLite connection to verify the queries

About the slmgr command

Hudi of data Lake (1): introduction to Hudi
随机推荐
关于结构体所占内存大小知识
Yunna | what are the main operating processes of the fixed assets management system
云呐|固定资产管理系统功能包括哪些?
What are the functions of Yunna fixed assets management system?
建立时间和保持时间的模型分析
The difference of time zone and the time library of go language
Hardware and interface learning summary
数据分析思维分析方法和业务知识——分析方法(二)
7.5模拟赛总结
Notepad + + regular expression replace String
18. (ArcGIS API for JS) ArcGIS API for JS point collection (sketchviewmodel)
多线程与高并发(8)—— 从CountDownLatch总结AQS共享锁(三周年打卡)
[designmode] adapter pattern
Configuring OSPF load sharing for Huawei devices
LeetCode 6004. Get operands of 0
Huawei equipment is configured with OSPF and BFD linkage
[Chongqing Guangdong education] reference materials for Zhengzhou Vocational College of finance, taxation and finance to play around the E-era
NSSA area where OSPF is configured for Huawei equipment
Atcoder beginer contest 258 [competition record]
Detailed explanation of APP functions of door-to-door appointment service