当前位置:网站首页>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
边栏推荐
- How to solve the problems caused by the import process of ecology9.0
- Tools to improve work efficiency: the idea of SQL batch generation tools
- 2022.7.5-----leetcode. seven hundred and twenty-nine
- Notepad + + regular expression replace String
- SQLServer连接数据库读取中文乱码问题解决
- Mysql - CRUD
- 关于slmgr命令的那些事
- Codeforces gr19 D (think more about why the first-hand value range is 100, JLS yyds)
- Date类中日期转成指定字符串出现的问题及解决方法
- 【QT】Qt使用QJson生成json文件并保存
猜你喜欢
随机推荐
Room cannot create an SQLite connection to verify the queries
Leetcode:20220213 week race (less bugs, top 10% 555)
LeetCode 斐波那契序列
Configuring OSPF load sharing for Huawei devices
MySql——CRUD
SQLServer连接数据库读取中文乱码问题解决
AtCoder Beginner Contest 258【比赛记录】
[noi simulation] Anaid's tree (Mobius inversion, exponential generating function, Ehrlich sieve, virtual tree)
Power Query数据格式的转换、拆分合并提取、删除重复项、删除错误、转置与反转、透视和逆透视
notepad++正則錶達式替換字符串
Go learning --- structure to map[string]interface{}
notepad++正则表达式替换字符串
Shardingsphere source code analysis
PHP determines whether an array contains the value of another array
JS 这次真的可以禁止常量修改了!
Global and Chinese markets for hinged watertight doors 2022-2028: Research Report on technology, participants, trends, market size and share
什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
OpenCV经典100题
Global and Chinese market of valve institutions 2022-2028: Research Report on technology, participants, trends, market size and share
Location based mobile terminal network video exploration app system documents + foreign language translation and original text + guidance records (8 weeks) + PPT + review + project source code