Python报错集合

ImportError: cannot import name ‘Feature‘ from ‘setuptools

查阅相关文档发现是setuptool版本的问题,python3源中的setuptools已经升级到46以上,所以导致pip安装失败。
解决方案,更新setuptools版本

pip install --upgrade pip setuptools==45.2.0

ValueError: ZIP does not support timestamps before 1980

安装的库是“click-7.1.2",用的是python setup.py install命令安装

解决办法

用 pip 试试

pip install click==7.1.2

或用国内的镜像,速度比较快:

python -m pip install click==7.1.2 -i https://pypi.tuna.tsinghua.edu.cn/simple

Inconsistent use of tabs and spaces in indentation

写Python程序的时候遇到和tabs、indentation有关的错误十有八九是缩进出了问题。
有的解释器是会区分四个空格和一个tab的。有的时候从Git下载的代码常会出现这样的不匹配问题。
解决办法见:https://blog.csdn.net/hhy_csdn/article/details/82263757

No axis named 2 for object type DataFrame

错误原因,df.iloc[]是中括号,我错误使用了小括号,df.iloc()报错。

dtype: object' is not compatible with origin='1970-01-01 08:00:00'; it must be numeric with a unit specified

需要将日期转换为数字才能使用,代码如下

Dataframe['new_column']=pd.to_datetime(pd.to_numeric(Dataframe['column'],errors='coerce'),errors='coerce',origin='1899-12-30',unit='D')

答案来自:https://stackoverflow.com/questions/63753525/changing-a-column-to-datetime-format-with-specified-origin

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

解决方法:把条件表达式里面的 and和or改为&和|就行

local variable referenced before assignment

在函数内部更改全局变量就会出现此错误。

对于全局变量的修改

  • 如果全局变量是int或者str,那么如果想要在函数中对函数变量进行修改,则需要先在函数内,声明其为global,再进行修改
  • 如果是list或者dict则可以直接修改

摘选:https://blog.csdn.net/weixin_48419914/article/details/122008139

WARNING: A newer version of conda exists.

问题
已经win10下安装完anaconda之后,在新建一个Python虚拟环境的时候出现问题

conda create -n py3.6 python=3.6
报错

==> WARNING: A newer version of conda exists. <==
  current version: 4.7.12
  latest version: 4.8.3
 
Please update conda by running
 
    $ conda update -n base -c defaults conda
使用报错提示的conda update -n base -c defaults conda解决不了这个问题。期间也尝试过重现安装anaconda也不行。

解决方法
注意对应的conda版本自己修改了。

conda install conda=4.8.3
查看conda信息

conda info


原文链接:https://blog.csdn.net/pursuit_zhangyu/article/details/106252145

Could not install packages due to an EnvironmentError

以selenium为例,直接在terminal里执行

python3 -m pip install selenium

可能会出现权限不够的报错

解决方法是,在安装代码后面加 --user

python3 -m pip install selenium --user

就可以安装成功。

posted @ 2022-06-16 22:04  C羽言  阅读(467)  评论(0)    收藏  举报