-
Python报错ERROR: Command errored out with exit status 1:
2019-08-22 16:12:59因为Pycharm最近老是弹出RELP COMMUNICATIONS,非常影响代码运行的效率。 REPL(Read-Eval-Print Loop),翻译过来就是“读取-求值-输出”循环,是...结果报错: ERROR: Command errored out with exit status 1: ...2020.08.24更新:似乎产生这个的原因,就是因为Python 2和Python 3默认的编码格式不一样。
Python 2是GBK,而Python 3是UTF-8。所以有些老旧的包在安装时,会产生编码的问题。
因为Pycharm最近老是弹出RELP COMMUNICATIONS,非常影响代码运行的效率。
REPL(Read-Eval-Print Loop),翻译过来就是“读取-求值-输出”循环,是一个简单的交互式的编程环境。
听起来似乎挺有用,所以想直接在Pycharm中pip这个REPL。
结果报错:
ERROR: Command errored out with exit status 1:
主要错误显示在最后几行:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 1246: illegal multibyte sequence
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.定位问题:
UnicodeDecodeError,表明是编码的问题。
具体就是在setup.py文件中的第10行和第17行,读取文件的编码方式为GBK,而并非UTF-8,因此报错使得无法安装。
更新成功解决的方法:
由于不能使用 Pycharm 里的 Project Interpreter。
解决思路:下载源码的包,进行代码改动之后install。
1、找到原始package的文件,找到报错的那一行。
REPL的官方地址是:https://github.com/mbr/repl。查看报错的setup文件的源码。
定位问题:源码中没有指定open时的编码方式,使得默认为gbk编码。
报错的源码:
def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read()
2、下载原始包文件后,解压找到setup.py文件,修改文件里的这一行,即加上encoding='utf-8',保存后打包为新的安装包。
修改后的代码:
def read(fname): return open(os.path.join(os.path.dirname(__file__), fname),encoding='utf-8').read()
3、输入 pip install repl-1.0.tar.gz,用新的安装包来进行install。成功!
这个问题困扰了我一周,后来发现其实解决方法非常简单!
解决问题最重要的是要定位报错产生的原因,然后根据原因一步步找到解决的方法。
-
Python报错:PermissionError: [Errno 13] Permission denied解决方案详解
2019-05-20 10:39:54使用python做数据集的过程中,报如下错误: 错误原因 报错翻译过来是: 权限错误:[errno 13]权限被拒绝: 错误产生的原因是文件无法打开,可能产生的原因是文件找不到,或者被占用,或者无权限访问,或者...报错信息
使用python做数据集的过程中,报如下错误:
错误原因
报错翻译过来是:
权限错误:[errno 13]权限被拒绝:
错误产生的原因是文件无法打开,可能产生的原因是文件找不到,或者被占用,或者无权限访问,或者打开的不是文件,而是一个目录。
解决方案
解决方案如下:
1.检查对应路径下的文件是否存在,且被占用。如果文件不存在,就找到对应文件即可;如果文件存在,被占用,将占用程序暂时关闭。
2.修改cmd的权限,以管理员身份运行。
3.检查是否是打开了文件夹。
-
Python报错:AttributeError
2018-10-08 22:48:48Python报错:AttributeError 这个错误就是说python找不到对应的对象的属性,后来我发现竟然是初始化类的时候函数名写错了: class Settings(): def _init_(self): self.scren_width=1200 self.screen_height...Python报错:AttributeError
这个错误就是说python找不到对应的对象的属性,后来我发现竟然是初始化类的时候函数名写错了:class Settings(): def _init_(self): self.scren_width=1200 self.screen_height=800 self.bg_color=(230,230,230)
不知道你看出哪错了没,百度了一下才发现__init__是两个下划线,两个下划线,两个下划线:
更改之后的代码:class Settings(): def __init__(self): self.scren_width=1200 self.screen_height=800 self.bg_color=(230,230,230)
更改之后错误就没有了
其实后来我也发现,当你把init函数写错的时候,它的颜色会提示你的,先来看错误的提示颜色:
再来看更改之后的提示颜色:
所以说,我们在写代码的时候也可以留意一下代码的提示颜色,有时候它会帮助你实时检查代码有没有错误,虽然这么多颜色,我也记不住。。。
在附带上python中常见的几种错误:
-
python 报错函数
2017-08-18 16:58:57python 报错函数import time
def writelog(s): #定义一个报错函数
t1= time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) #本地时间
t2=("%s" % __file__) # 当前程序的位置(包含程序名)
with open ('文件地址','a') as f:
a ='{},{},{},\n\r'.format(t1,t2,s) #将时间和程序添加
f.write(a)#追加
try:
writelog('------start------')
中间插入我们想运行的程序
except Exception as e:
writelog(e)
finally:
writelog('-----end------')
-
安装anaconda时python报错
2020-03-25 23:54:13安装anaconda时python报错 请问这个warning该如何解决? 查询python版本为3.7.4 ``` C:\Users\lenovo>python --version ... -
python报错invalid character in identifier
2017-11-15 15:39:25python报错invalid character in identifier,意思就是“标识符中的无效字符”,检查下有没有字符是中文的,把中文字符改成英文字符再运行就OK啦~ -
python 报错:Empty suite
2019-06-17 13:41:00问题:python 报错:Empty suite 原因: 1.类名用Test命名 2.代码中使用了main函数调用类中的内容 所以解决办法:只要不满足上面的某一条件就行 本博客仅仅记录我自己遇见过的bug,仅仅用于个人备查。 如果不是很... -
python报错MemoryError
2016-11-14 14:49:45python报错MemoryErrorpython 32bit 最大只能使用 2G 内存,坑爹之处,超过 2G 报错MemoryError。而 64bit python则无此限制,所以建议使用 64bit python。 可能存在的问题:以前 numpy、scipy 官方的库只支持 32... -
Python报错: Using TensorFlow backend
2020-03-10 17:48:51Python报错: Using TensorFlow backend 环境: 系统:win10 pycharm2017 问题描述 导入keras库运行时,Python总是出现Using TnesorFlow backend报错。 解决过程 网上有多种解决方案,下面列举并说明效果。 ... -
Python报错信息与原因分析
2017-09-04 20:37:39包含自己整理的关于Python报错信息 -
Python 报错 SyntaxError: invalid syntax 解决方法
2020-08-13 15:52:22Python 报错 SyntaxError: invalid syntax 解决方法 -
python报错IndentationError: unexpected indent
2018-11-18 20:00:24python报错IndentationError: unexpected indent 报错原因是代码的缩进出了问题 如图是print(result.head(10))缩进了出了问题 -
Python报错ZeroDivisionError: float division by zero
2018-07-30 23:28:23Python报错ZeroDivisionError: float division by zero 报错:ZeroDivisionError: float division by zero 原因:被除数为0 -
python3.5 pip安装mysql-python报错解决方法
2016-08-29 19:52:02python3.5 pip安装mysql-python报错解决方法 安装mysql-python报错,按网上的方法也没解决,后来发现mysql-python只更新支持到了python3.4,好吧。。。又不是除了mysql-python没别的了,可以用pymysql替代mysql-... -
python报错:No matching distribution found for yaml
2019-06-14 14:56:20问题:python报错:No module named ‘utils’ 执行pip install yaml时候报错Could not find a version that satisfies the requirement yaml No matching distribution found for yaml. 实际需要执行:pip install ... -
python报错1-'int' object is not iterable('int'对象不可迭代)
2019-05-21 19:01:17python报错:‘int’ object is not iterable 含义:'int’对象不可迭代 解决办法:不能直接用int进行迭代,而必须加个range 如: for i in range(ix): -
Python报错:OSError: cannot open resource
2020-02-13 11:03:07Python报错:OSError: cannot open resource 今天借助Python第三方库写了一个简单的生成词云的编程,但在使用wordcloud生成词云过程中,出现了OSError: cannot open resource错误,通过断点调试并查看了一些网上的... -
Python报错module 'scipy.misc' has no attribute 'imsave'
2018-12-14 10:27:49Python报错module 'scipy.misc' has no attribute 'imresize' Python报错module 'scipy.misc' has no attribute 'imsave' 此类的报错,可安装 Pillow 解决 pip install Pillow 或pip3 install Pillow... -
python报错 TypeError: an integer is required
2019-09-27 18:06:51在本地使用socket向NetAssist传送数据的时候,执行python文件后发现报出python 报错TypeError: an integer is required错误 代码: 1 #!/usr/bin/env python3 2 from socket import * 3 udpSocket = socket(AF_... -
python报错:IndentationError: unexpected indent
2015-07-20 14:43:58python报错:IndentationError: unexpected indent -
python报错TypeError: must be str, not int
2020-03-03 09:41:16python报错TypeError: must be str, not int 字符串拼接一个整型变量报错,代码如下 for i in range(1,586): res = 'test' + i 报错信息如下 TypeError: must be str, not int 1个回答 第一种方法: ... -
Python 技巧篇-如何避免python报错导致强制关闭窗口
2019-02-23 21:42:09Python 技巧篇-如何避免python报错导致强制关闭窗口。 运行窗口是我们获取信息的重要途径,但是运行的过程中,窗口自己就关了,我么甚至不能知道程序是运行完了还是报错了。比如:有时也就眼前一闪,大概好像看到有... -
mac安装mysql-python报错历程
2018-07-06 11:50:16mac安装mysql-python报错历程 python标准数据库接口为python DB-API, python DB-API为开发人员提供了数据库应用编程接口。python数据库接口支持非常多的数据库,不同的数据库需要下载不同的DB-API模块。DB-API是... -
Python报错: python setup.py egg_info" failed with error code 1
2017-05-03 11:18:27Python报错: Command “python setup.py egg_info” failed with error code 1 in /private/var/folders/0m/7s1flm9j03d35pkr92jcsv3w0000gq/T/pip-build-fK6SMy/aiohttp/这是因为你电脑同时用 Python2.7+ 和3.5+ ... -
【python】python报错IndentationError: unindent does not match any outer indentation level
2018-05-05 17:55:50python报错IndentationError: unindent does not match any outer indentation levelIndentationError: unindent does not match any outer indentation level翻译---缩进错误:UNDENT与任何外部缩进级别不匹配原因... -
Python报错ModuleNotFoundError: No module named 'numpy'
2019-11-24 15:21:50Python报错ModuleNotFoundError: No module named ‘numpy’ 这种情况一般是缺少numpy所致,需要安装numpy。 安装numpy的时候需要先更新pip,使用最新版的pip来安装: python -m pip install --upgrade pip 然后 ... -
python报错No module named XXX解决方法
2019-09-11 16:58:18起因就是执行一个python程序,在这个程序中引入了另一个文件夹中 的一个 python 文件中的变量。 所以在这个程序中使用import引入另一个文件: import abc.ABC # (abc是文件夹名,ABC是python文件名) 结果在... -
解决python报错RuntimeError: lost sys.stdout
2019-08-01 09:04:42解决python报错RuntimeError: lost sys.stdout 对于一名初学python的小白来说,配置python环境已经非常让人头疼,各种报错更是让人自闭,接下来分享一种报错,解决起来非常简单(在四处碰壁之后)如下图所示: 本次... -
python报错:SyntaxError: encoding problem: utf8
2020-11-12 17:27:00python报错:SyntaxError: encoding problem: utf8 如题。 第一行就报错,但我已经检查了文件的编码,确实是utf8。 此时使用notepad++打开文件,在右下方可以看到文件的换行风格。(CR LF即为windows风格, LF为unix...