每次配环境都要百度百度百度,我决定把他们都记录下来,防止以后浪费时间
python:
1. bash: /usr/bin/python: Too many levels of symbolic links(符号链接级别过多)
相关命令:
(1)查看都有哪些链接
ls -l /usr/bin | grep python
(2)删除链接
sudo rm /usr/bin/python
(3)添加链接(python3指向3.5版本)
sudo ln -s /usr/bin/python3.5 /usr/bin/python3
sudo ln -s /usr/local/bin/python3.5 /usr/bin/python
2.相关命令
(1)关于新建/删除/修改软连接的命令https://blog.youkuaiyun.com/weixin_39998462/article/details/111437863
(2)卸载python
sudo apt autoremove python3.6
(3)清除python软链接
rm -rf /usr/bin/python
或者
cd /usr/bin
sudo rm -rf python
(4)查看python文件夹
ls /usr/bin/python* -l
(5)如果误删了python的文件夹,可以在别的相同系统的电脑上进行拷贝补救。例误删了python3.5文件,从别的系统拷贝一份放到桌面上,把桌面上的python3.5文件复制到/usr/bin文件夹下
#进入root用户
sudo su
#输入root密码
#进入桌面
cd desktop
#复制
cp -r python3.5 /usr/bin
(6)pip安装时间超时问题
pip --default-timeout=100 install -U xxx
3.由于版本问题,代码报错总结
(1)AttributeError: module 'tensorflow._api.v2.train' has no attribute 'GradientDescentOptimizer'
原来:optimizer = tf.train.GradientDescentOptimizer(0.5)
改为:
optimizer = tf.compat.v1.train.GradientDescentOptimizer(0.5)
(2)AttributeError: module 'tensorflow' has no attribute 'random_uniform'
原来:tf.random_uniform([1],-1.0,1.0)
改为:
tf.random.uniform([1],-1.0,1.0)
(3)RuntimeError: `loss` passed to Optimizer.compute_gradients should be a function when eager execution is enabled. 或者 RuntimeError: The Session graph is empty. Add operations to the graph before calling run().
添加一行:
tf.compat.v1.disable_eager_execution()
(4)AttributeError: module 'tensorflow' has no attribute 'initialize_all_variables' 或者 AttributeError: module 'tensorflow' has no attribute 'global_variables_initializer' 或者RuntimeError: tf.placeholder() is not compatible with eager execution.
改为:
init = tf.compat.v1.global_variables_initializer()
(5)AttributeError: module 'tensorflow' has no attribute 'Session'
改为:
sess = tf.compat.v1.Session()
(6)AttributeError: module 'tensorflow' has no attribute 'mul'
改为:
tf.multiply()
(7)TypeError: reduce_sum() got an unexpected keyword argument 'reduction_indices'
运行代码:
loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction), reduction_indices=[1]))
报错。原因:在reduce_sum()
函数中参数:reduction_indices
已经被废弃,取而代之的是参数:axis
改为:
loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction), axis=[1]))
(8)windows10解决报错“ModuleNotFoundError: No module named 'tkinter'”
ps:我是看了这个博文解决的https://www.pianshen.com/article/8476118338/,我给摘抄到我这里了,并截了几张图片
原因:tcl 是系统自带的库,一般不会缺失,如果出现错误,一般就是 Python 安装时没有安装相应的包。
如果出现上面错误,一般在 Python 的根目录不会有名为 “tcl” 的文件夹(见下图)。
解决方法:
再次点击exe安装包,选择modify 选择tcl/tk,然后next 安装
(9)懒得粘了,直接上链接https://blog.youkuaiyun.com/qq_36512295/article/details/100024979
3. 查看python安装在在哪个位置
whereis python
4.添加软链接(/usr/local/python/bin/python3.6m :python3版本安装的位置,/usr/bin/python3:链接到python3)
sudo ln -s /usr/local/python/bin/python3.6m /usr/bin/python3