这里写目录标题

  • Python3.7 使用时报错
  • wandb
    • Login
  • dataloader
    • RuntimeError: freeze_support()
      • 全局变量:
  • OpenMP
    • libiomp5md.dll
  • Numpy
    • matrix multiplication

Python3.7 使用时报错

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1091)>

Solution1
将以下block copy至要跑的代码前。

import urllib.request
import ssl
def main():ssl._create_default_https_context = ssl._create_unverified_contextresponse = urllib.request.urlopen('https://www.python.org')Your codes start here......

Solution2

conda install -c anaconda certifi

wandb

Login

每个新项目都要login一次wandb,在https://wandb.ai/ 找到API 直接填入terminal,例如:

wandb login 123abc42623e2649730766b922bb71f40effbcc6

dataloader

RuntimeError: freeze_support()

BrokenPipeError: [Errno 32] Broken pipe
File “xxxx\python3.7\lib\multiprocessing\spawn.py”, in _check_not_importing_main is not going to be frozen to produce an executable.

RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom in the main module:

Solution:
将程序用if __name__ == '__main__':包裹起来,或者更全面:

if __name__ == '__main__':freeze_support()

(1)产生原因是Windows没有fork,只有Unix有,是一个可以帮助child process识别parent process 的
(2)对于python 里的multiprocessing, if __name__ == '__main__':不可少。

全局变量:

Bear in mind that if code run in a child process tries to access a global variable, then the value it sees (if any) may not be the same as the value in the parent process at the time that Process.start was called.

However, global variables which are just module level constants cause no problems.Safe importing of main module. Make sure that the main module can be safely imported by a new Python interpreter without causing unintended side effects (such a starting a new process).

For example, using the spawn or forkserver start method running the following module would fail with a RuntimeError:

from multiprocessing import Process
def foo():print('hello')
p = Process(target=foo)
p.start()

Instead one should protect the “entry point” of the program by using if __name__ == '__main__':as follows:

from multiprocessing import Process, freeze_support, set_start_method
def foo():print('hello')if __name__ == '__main__':freeze_support()set_start_method('spawn')p = Process(target=foo)p.start()

The freeze_support() line can be omitted if the program will be run normally instead of frozen.This allows the newly spawned Python interpreter to safely import the module and then run the module’s foo() function.

Similar restrictions apply if a pool or manager is created in the main module.

OpenMP

libiomp5md.dll

MP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.

Solution:

import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"

Numpy

matrix multiplication

两个Matrix相乘,其中一个要用inverse 形式

A = np.array( [[2, 3, -1], [-4, 0, 1], [0, 1, -2] ])
Y = np.array( [6, 7, 1])
X = np.matmul(Ainv, Y)
Ainv = np.linalg.inv(A)
X = np.matmul(Ainv, Y)
print(Ainv@Y)
print(X)

Python日常bug相关推荐

  1. Python:Bug 官网不要了,全迁去 GitHub

    近几年,GitHub 开发者数量逐年上升,仅过去一年 GitHub 的新增用户便有 1600 万人,总用户数更是达到了 7300 万--在开源浪潮席卷全球中,GitHub 无疑成为了许多开发者迈入开源 ...

  2. Nature论文爆出千行Python代码Bug,或影响百篇学术论文

    你的论文借鉴了 Nature 文章的代码?对不起,论文可能要重新写了. 在 10 月 8 日发表于<ACS Publication>期刊的一篇论文中,来自夏威夷大学的 Jayanti Bh ...

  3. Python:Bug 官网不要了,全迁去 GitHub!

    整理 | 郑丽媛 出品 | CSDN(ID:CSDNnews) 近几年,GitHub 开发者数量逐年上升,仅过去一年 GitHub 的新增用户便有 1600 万人,总用户数更是达到了 7300 万-- ...

  4. Python日常+笔面试

    Python日常学习 三维转二维: 例:X(200,200,106)->newX(40000,106) newX = np.reshape(X, (-1, X.shape[2])) 二维变三维: ...

  5. Python日常(13):字符串的格式化输出(format方法和%输出)

    目录 前沿 字符串的格式化输出 (1)format方法 ①基本输出格式 ②实例 (2)%输出方法 ①基本输出格式 ②实例 作者的话 参考文献 前沿 前面我们基本上已经把python基础的操作初略的说完 ...

  6. python日常总结

    项目场景: `python日常简单库的使用如:txt文件操作.numpy操作.字典操作.取整操作等. python读写txt # 1.读取所有行 with open('test.txt','r', e ...

  7. python日常记账本源代码,基于PySide6,支持快速查询、绘制图表

    python日常记账本源代码,基于PySide6(Qt for Python 6)的账本,界面简洁.功能强大,支持保存文件.快速查询.绘制图表等,是平时记账的不错选择.账目查询.账本编辑.添加/删除. ...

  8. Python日常用法—将列表信息写入到csv文件、列表中的元素直接更改

    Python日常用法-将列表信息写入到csv文件 1.模板 # 编写数据 import csvdata_list = [{'皇马球员': 'C罗', '号码': '7', '国籍': '葡萄牙'}, ...

  9. 【python日常学习】爬取4K桌面壁纸

    [python日常学习]爬取4K桌面壁纸 这个网站都是4K的桌面壁纸. 不多说,直接上代码 import re import requests import osdef get_page():page ...

最新文章

  1. linux 脚本的作用,shell export 作用
  2. 一文综述OpenCV基础+计算机视觉基础
  3. MySQL事务的提交
  4. 三维重建:三维空间中平面的旋转公式
  5. 数据结构教程网盘链接_数据结构101:链接列表
  6. React开发(282):公共组件可以提升一下文件层级
  7. [js] axios为什么可以使用对象和函数两种方式调用?是如何实现的?
  8. java reader_Java Reader ready()方法与示例
  9. fx5u以太网通讯设置_操作示例 | 实现S7300和FX5U的数据交换
  10. Firefox 使用 Chrome 浏览器的 PDF 和 Flash 插件
  11. VC6.0创建文件夹
  12. unity html get post,使用C#开发HTTP服务器系列之实现Get和Post
  13. Anaconda spyder下载第三方包
  14. Vue图片放大镜插件
  15. 解决AD13不能复制原理图的问题
  16. 綫程池 部分代碼實現 筆記
  17. mysql flush logs时出现ERROR 1105
  18. Python进阶学习之超市结账时间计算
  19. linux $ PATH=~/bin:$PATH这个命令是什么意思?
  20. 学习网站建设必备知识

热门文章

  1. onkeydown、onkeypress和onkeyup的区别介绍
  2. 1376:信使(msner)
  3. Fatfs U盘写入文件遇到的问题
  4. CAN通信讲解(2)——数据帧和遥控帧
  5. 设计模式-对象池技术
  6. 《八方旅人》:多人多线的JRPG,如何给予玩家足够的“代入感”?
  7. Opencv图像偏色检测
  8. 【分享】FME小白式安装教程及教学网站
  9. 物联网毕业设计 单片机智能路灯系统
  10. 设计一个在一百万个数字中求十个最大的数算法