目录

Python备忘

报error: invalid command ‘bdist_wheel’

1
pip install wheel

时间转换

Python获取秒级时间戳与毫秒级时间戳

ubuntu18.04使用pip安装某包时报错

https://note.youdao.com/yws/public/resource/41112cc5871c7abf8ae2c90c3f174804/xmlnote/image-20200401153406748_4d9d6a45b0f34a249060fa6f5ce92a44/23489

1
2
3
4
prehisle@ubuntu:~/tmp/tyoudaoimg$ pip install -i https://pypi.org/simple youdaopic==0.0.9
Collecting youdaopic==0.0.9
  Could not find a version that satisfies the requirement youdaopic==0.0.9 (from versions: 0.0.1)
No matching distribution found for youdaopic==0.0.9

改用pip3安装成功

windows下pip安装包时报错basetsd.h未找到

1
Build error on Win 10: Cannot open include file: 'basetsd.h': No such file or directory

参考:https://github.com/Azure/azure-iot-sdk-python/issues/82

1
2
Launch Microsoft Visual C++ Build Tools setup again and also select windows 8.1 / 10 SDK depending upon your OS:
https://stackoverflow.com/a/42624713/4063622

windows下auto-py-to-exetkinter not found

1
2
3
G:\2020\youdaopic\build>auto-py-to-exe
Error: tkinter not found
For linux, you can install tkinter by executing: "sudo apt-get install python3-tk"

重新安装python,勾选安装tcl/tk and IDLE

报错No module named PIL

1
pip install image

openUnicodeDecodeError

1
UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 23: illegal multibyte sequence

加入参数encoding,如下

1
open(filename, 'r', encoding="utf-8")

使用kill命令发送ctrl+c(KeyboardInterrupt)结束python程序

1
kill -SIGINT 23354

logging.basicConfig中配置了logging.INFO,logging.info仍不生效的问题

  • 需要把logging.basicConfig调到输出第一条log之前,可以放在import logging之后