1. No module named _tkinter
solution:
sudo apt-get install python3-tk
For python 2.7和3.6:
sudo apt-get install python3.6-tk # python2.7-tk
notes
In python 3 Tkinter is renamed to tkinter
links
https://stackoverflow.com/questions/6084416/tkinter-module-not-found-on-ubuntu
https://blog.csdn.net/qq_33144323/article/details/80556954
https://www.jianshu.com/p/e041692438cc
2. 各种error
2.1 python安装opencv后import报错
python安装opencv:pip install opencv-python
在python3中,依次报错:
ImportError: libSM.so.6: cannot open shared object file: No such file or directory
ImportError: libXrender.so.1: cannot open shared object file: No such file or directory
ImportError: libXext.so.6: cannot open shared object file: No such file or directory
分别安装对应的软件包可解决:
apt-get install libsm6
apt-get install libxrender1
apt-get install libxext-dev
# apt-get install libxext6
在python2中,报错
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
对应解决方式:
apt-get install libglib2.0-0
2.2 一些ImportError和共享库缺失错误:
----- libGL.so.1: cannot open shared object file (link)
sudo apt-get update
sudo apt-get install libgl1-mesa-glx
----- error while loading shared libraries: libjpeg.so.8: cannot open shared object file
----- error while loading shared libraries: libpng12.so.0: cannot open shared object file
----- error while loading shared libraries: libtiff.so.5: cannot open shared object file
----- error while loading shared libraries: libjasper.so.1: cannot open shared object file
apt-get install libjpeg8 libpng12.0 libtiff5 libjasper1
2.3 OSError
----- OSError: libgtk-x11-2.0.so.0: cannot open shared object file
apt-get update
apt-get install libgtk2.0
2.4 AttributeError
----- AttributeError: module ‘cv2.cv2’ has no attribute ‘estimateRigidTransform’
----- 当前opencv版本为4.1.0.25,上述函数已被遗弃,版本回退可解决 ref
pip uninstall opencv-python
pip uninstall opencv-contrib-python
pip install opencv-python==3.4.5.20
pip install opencv-contrib-python==3.4.5.20
3. 安装package
3.1 pyflann
pip install pyflann
# --------------------- 1. 若使用时报错
sudo 2to3 -w [pyflann安装路径]
# --------------------- 2. 如何查看pyflann安装路径
1.试试 whereis pyflann
2.终极 pip uninstall pyflann(列出路径后,输入n拒绝卸载)
3.2 安装screen | gpustat | htop
apt-get install screen # 可能需要先执行 apt-get update
apt-get install htop
pip install gpustat
3.3 保存环境包列表
pip freeze > requirements.txt
pip install -r requirements.txt
4. nvidia驱动版本低
NVIDIA driver on your system is too old (found version 9020). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver.
-
根据提示,到官网下载对应的驱动并运行
sh NVIDIA-Linux-x86_64-430.40.run
-
第一步之前,其实应该先卸载旧版本驱动(以为会自动覆盖,结果bug,只好分别手动卸载再重装)
摘要
sudo nvidia-uninstall
sudo apt-get purge nvidia-*
sudo apt-get remove --purge nvidia-*
sudo add-apt-repository ppa:graphics-drivers/ppa
sh NVIDIA-Linux-x86_64-430.40.run --uninstall
参考 1 2 3 -
其他设置
sudo /sbin/telinit 3 # To get out of X
sudo /sbin/telinit 5 # to return to X afterwards
ref: 1 -
关于驱动版本
nvidia-smi # 可看到驱动版本号,并且也显示了一个cuda版本号,这个cuda估计是驱动希望的版本
cat /usr/local/cuda/version.txt # 实际的驱动版本号
5. TypeError: can’t concat str to bytes
label = np.asarray([123.0, 432.0],dtype=np.float32)
s = label.tostring() + ‘’
基于python2.7编写的数据处理代码,在python3中报上述错误。原因是两者解码方式有别:
python3中:b’\x00\xc3\tG\x00\x9a\x0bG’,前面有字样‘b’
python2中:’\x00\x00\xf6B\x00\x00\xd8C’
解决方式:
label.tostring().decode(‘utf8’,‘ignore’)
# 如果解码后发现汉字乱码,就要改成gbk格式试一下:decode(“gbk”)
6. Shell脚本
因为是远程服务器,顺手就在windows(pycharm)下编写了test.sh文件,拿到linux上运行是会报错的,因为两者使用的格式不同。我们需要把dos格式转换为unix格式:
- 在vim中打开tesh.sh,命令模式下 :set ff=unix (set ff?可查看当前文件格式)
- apt-get install dos2unix,然后 dos2unix test.sh
坑就在这里, 格式转换可能并不靠谱,结果就是会各种解析错误。
【解决】直接在linux中用vim等编辑器
\*/ 存疑bug
1. mxnet导入报错
import mxnet as mx
报错 Segmentation fault:11
同样的服务器地址,同样的docker配置,安装同样的anaconda和mxnet版本,之前都okay,现在装完就报Seg错误。一气之下不管了,结果环境第二天自己又好了… (问题解决的可能原因:对2.1中的导入报错,进行了相应安装,即可能跟opencv有关)
1.1 关于mxnet的其他补充
os.environ[‘CUDA_VISIBLE_DEVICES’] = ‘2,3’
os.environ[‘MXNET_CPU_WORKER_NTHREADS’] = ‘20’ # Set to a larger number to use more threads.