Python踩坑记录
记录使用Python过程中遇到的问题,既长个记性也避免别人踩坑
Drcxzhou
这个作者很懒,什么都没留下…
展开
-
【解决】ValueError:the environment variable is longer than 32767 characters
报错:值错误:环境变量超过32767字符原因:Python+Gurobi求解MILP问题时,不读取系统变量'LD_LIBRARY_PATH',而是在GUROBI_CMD类actualSolve方法中生成,生成时使用“+=”进行累加,故在使用拉格朗日松弛等迭代算法时会超出路径长度上限。解决:打开solvers.py,找到函数actualSolve:修改为如下:...原创 2019-12-16 15:03:24 · 1523 阅读 · 1 评论 -
【解决】引入包from compiler.ast import flatten出错提示无该包
报错:引入包from compiler.ast import flatten时出错提示无该包原因:代码为python2版本,当前环境为python3,而python3删除了该包解决:以下段代码代替import collectionsdef flatten(x): result = [] for el in x: if isinstance(x, collec...原创 2019-12-16 15:01:00 · 3227 阅读 · 0 评论 -
【解决】python 换源安装解决报错Read timed out
报错:pip._vendor.urllib3.exceptions.ReadTimeoutError:HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out.原因:连接超时解决:pip install --default-timeout=1000 Pillow人工修改超时时间,或者更换国内源:...原创 2019-12-16 14:58:55 · 415 阅读 · 0 评论 -
【解决】报错启动器错误,Fatal error in launcher: Unable to create process using……
报错:Fatal error in launcher: Unable to create process using……原因:需要i重装pip解决:python -m pip install --upgrade --force-reinstall pip原创 2019-12-16 14:55:24 · 484 阅读 · 0 评论 -
【解决】pip安装模块时,无法卸载旧版本的模块包
报错:ERROR: Cannot uninstall ‘PyYAML’. It is a distutils installed project and thus we cannot accurately原因:解决:pip install PyYAML==5.1.1 --ignore-installed原创 2019-12-16 14:52:20 · 1177 阅读 · 0 评论 -
【解决】pip安装时提示属性错误,无对应版本version
注,报错以当时实际报错为例,可以举一反三。2019.12.04报错:AttributeError: module ‘numpy’ has no attribute ‘version’原因:numpy版本不匹配解决:pip uninstall numpy pip install numpy报错:ERROR: Cannot uninstall ‘PyYAML’. It is a d...原创 2019-12-04 22:26:40 · 1496 阅读 · 0 评论