相关疑难解决方法(0)

使用Flask_Security进行FlaskWTFDeprecationWarning

每次使用Flask Security时都会收到警告.

FlaskWTFDeprecationWarning: "flask_wtf.Form" has been renamed to "FlaskForm" 
and will be removed in 1.0.
Run Code Online (Sandbox Code Playgroud)

这是Flask Security的问题还是我可以解决的问题?我正在使用Flask-Security == 1.7.5

from flask_security import current_user, login_required, RoleMixin, Security, \
SQLAlchemyUserDatastore, UserMixin, utils
Run Code Online (Sandbox Code Playgroud)

我似乎没有直接导入Flask_WTF.

python flask flask-security

6
推荐指数
2
解决办法
5734
查看次数

标准化包含过大值的数据集

我使用 preprocessing.scale astype('float64') 将特征标准化为 mean=0 和 sd=1。我收到以下警告:

用户警告:将数据居中时遇到数值问题,可能无法解决。数据集可能包含太大的值。您可能需要预先缩放您的功能。warnings.warn("遇到数值问题"

这是数据集的示例:

    col1    col2    col3    col4    col5    col6    col7    col8    col9    col10   col11   col12   col13
0   327 143.04  123.66  101.71  89.36575914 0.668110013 84.13713837 588.103818  633.6584113 525.5505746 132.966095  13.05099964 131.7220566
1   1010    188.98  176.78  137.33  89.36575914 0.620949984 40.52060699 1413.802012 3705.255352 1641.459378 106.3353716 7.69299984  472.4249759
2   1485    166.67  141.72  111.07  98.91169739 0.979290009 100 3580.441388 4327.644518 3242.16829  111.2140427 13.05300045 1164.119187
3   78  54.27   83.01   161.74  95.0061264  0.968744297 100 35644.07894 37765.71684 15667.95157 106.3043671 7.448999882 850.651571
4   591 …
Run Code Online (Sandbox Code Playgroud)

python scaling normalization scikit-learn

6
推荐指数
1
解决办法
5987
查看次数

运行 python 脚本时如何抑制警告?

我正在尝试抑制警告。

这是我的 esri python 版本

蟒蛇-V

Python 2.7.16

我试过这个

python.exe -W 忽略 GET_ESRIGIS_WEB_TOKEN.py

但它给出了这个错误

忽略无效的 -W 选项:无效操作:'“忽略”

我究竟做错了什么?

ps:这是帮助(请参阅下面的 -W 选项)

python.exe -h
Run Code Online (Sandbox Code Playgroud)

-W arg :警告控制;arg 是 action:message:category:module:lineno 也是 PYTHONWARNINGS=arg

用法: python.exe [选项] ... [-c cmd | -m 模组 | 文件| -] [参数] ...
选项和参数(以及相应的环境变量):
-b :发出有关将 bytearray 与 unicode 进行比较的警告
         (-bb:问题错误)
-B :导入时不要写入 .py[co] 文件;还有 PYTHONDONTWRITEBYTECODE=x
-c cmd :程序作为字符串传入(终止选项列表)
-d :调试解析器的输出;还有 PYTHONDEBUG=x
-E :忽略 PYTHON* 环境变量(例如 PYTHONPATH)
-h :打印此帮助消息并退出(也--help)
-i :运行脚本后交互式检查;甚至强制提示
         如果 stdin 看起来不是终端;还有 PYTHONINSPECT=x
-m mod :将库模块作为脚本运行(终止选项列表)
-O …

python warnings

6
推荐指数
1
解决办法
3万
查看次数

MySQL'IF EXISTS'命令在python中使用时会导致错误

我正在尝试学习如何在python中使用SQL与MySQL(因为我的所有项目都使用MySQL),但它似乎与IF EXISTS语句有问题.

从命令行:

DROP TABLE IF EXISTS accessLogs;
Run Code Online (Sandbox Code Playgroud)

收益:

Query ok, 0 rows affected, 1 warning (o.00 sec)
Run Code Online (Sandbox Code Playgroud)

并且表已成功删除.但是,如果我使用python的execute()方法:

cursor.execute("DROP TABLE IF EXISTS accessLogs")
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

pydbCreate.py:12: Warning: Unknown table 'accessLogs'
    cursor.execute("DROP TABLE IF EXISTS accessLogs")
Run Code Online (Sandbox Code Playgroud)

有没有办法解决这个错误?并且其他任何MySQL命令会导致类似的问题吗?

python mysql

5
推荐指数
1
解决办法
5781
查看次数

PDFminer:PDFTextExtractionNotAllowed错误

我试图从pdfs中提取文本我已经从互联网上删除了,但当我尝试下载它们时,我收到错误:

File "/usr/local/lib/python2.7/dist-packages/pdfminer/pdfpage.py", line 124, in get_pages
    raise PDFTextExtractionNotAllowed('Text extraction is not allowed: %r' % fp)
PDFTextExtractionNotAllowed: Text extraction is not allowed <cStringIO.StringO object at 0x7f79137a1ab0>
Run Code Online (Sandbox Code Playgroud)

我检查了stackoverflow,其他有此错误的人发现他们的pdf用密码保护.但是,我可以通过我的mac上的预览访问pdfs.

有人提到预览可能无论如何都可以查看安全的pdf,所以我也在Adobe Acrobat Reader中打开文件,但仍然可以访问pdf.

以下是我从以下网站下载pdf的示例:http: //www.sophia-project.org/uploads/1/3/9/5/13955288/aristotle_firstprinciples.pdf

我发现如果我手动打开pdf并将其作为pdf重新导出到同一个文件路径(基本上用'new'文件替换原始文件),那么我就能从中提取文本.我猜这与从网站下载它们有关.我只是使用urllib下载pdfs,如下所示:

if not os.path.isfile(filepath):
    print '\nDownloading pdf'
    urllib.urlretrieve(link, filepath)
else:
    print '\nFile {} already exists!'.format(title)
Run Code Online (Sandbox Code Playgroud)

我也尝试将文件重写为新的文件路径,但它仍然导致相同的错误.

if not os.path.isfile(filepath):
    print '\nDownloading pdf'
    urllib.urlretrieve(link, filepath)

    with open(filepath) as f:
        new_filepath = re.split(r'\.', filepath)[0] + '_.pdf'
        new_f = file(new_filepath, 'w')
        new_f.write(f.read())
        new_f.close()

    os.remove(filepath)
    filepath = new_filepath …
Run Code Online (Sandbox Code Playgroud)

python pdf text nlp pdfminer

5
推荐指数
2
解决办法
4617
查看次数

FutureWarning:pandas.util.testing 已弃用。请使用 pandas.testing 中公共 API 中的函数

我已经看到了其中几个问题以及有关这一切的一些答案,但是要么我超级愚蠢并且无法弄清楚它们的含义,要么我只是非常愚蠢并且我做错了

我使用 Pandas 和 Pandas_datareader 收到此警告

“您可能会在 pandas_datareader 中找到‘util.testing’代码,它与 pandas 是分开的。”

这是我看到的答案之一,我不明白如何修复它,我没有任何具有“until.testing”的代码,所以我不知道在它不存在时删除它并添加它什么也没做,但由于警告,我的程序无法在我的树莓派上运行,这是预期的位置。

请帮忙

python-3.x pandas pandas-datareader

5
推荐指数
1
解决办法
7701
查看次数

打印时 pyodbc 弃用警告

当我运行print(cursor.fetchone())(pyodbc 包)时,我收到以下警告:

main.py:33: DeprecationWarning: PyUnicode_FromUnicode(NULL, size) is deprecated; use PyUnicode_New() instead
Run Code Online (Sandbox Code Playgroud)

这正常吗?我试图获取的数据类型如下: 在此输入图像描述

我正在使用 Python 3.10.2 和 MSSQL。

谢谢!

python sql-server pyodbc deprecated

5
推荐指数
0
解决办法
4619
查看次数

在 keras 中禁用张量流回溯警告

我已经创建了 keras 功能 API 模型,现在我正在尝试研究它的层输出,为从原始模型的输入开始到我选择的层结束的每一层创建子模型。我不明白在没有得到的情况下这样做的正确方法是什么

WARNING:tensorflow:11 out of the last 11 calls to 
<function Model.make_predict_function.<locals>.predict_function at 0x7fb8ebc92700> 
triggered tf.function retracing.
Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly 
in a loop, (2) passing tensors with different shapes, 
(3) passing Python objects instead of tensors. 
For (1), please define your @tf.function outside of the loop. 
For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes 
that can avoid unnecessary retracing. 
For (3), …
Run Code Online (Sandbox Code Playgroud)

python keras tensorflow

4
推荐指数
1
解决办法
2671
查看次数

如何删除有关 n_estimators 将从 0.20 版本中的 10 更改为 0.22 版本中的 100 的警告?

运行其他功能良好的代码,我不断在 PyCharm 的控制台中收到以下消息(查看“控制台中的响应”:FutureWarning: The default value of n_estimators will change from 10 in version 0.20 to 100 in 0.22. "10 in version 0.22 中的 0.20 到 100。”,FutureWarning))。此外,该警告已多次列出。

到处查看,我了解到删除它的一种方法是将 n_estimators 从 10 更改为 100,从而扩展“森林中的树木”。然而,多次尝试都失败了。

from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100) <== added this line; not sure, if ok!
random_forest_classifier = RandomForestClassifier()
random_forest_classifier.fit(X_train, y_train)
y_pred_rfc = random_forest_classifier.predict(X_test)

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
warnings.simplefilter(action='ignore', category=DeprecationWarning)
warnings.simplefilter(action='ignore', category=RuntimeWarning)

print("\nConfusion Matrix")
cm_random_forest_classifier = confusion_matrix(y_test,y_pred_rfc)
print(cm_random_forest_classifier, end="\n\n")

print("\nCalculating the accuracy from the confusion matrix for Random …
Run Code Online (Sandbox Code Playgroud)

python-3.x random-forest scikit-learn

3
推荐指数
1
解决办法
2万
查看次数

如何摆脱 NaturalNameWarning?

我的脚本正在做以下事情:

  1. 从二进制trc文件读取时间序列(UHF 测量)
  2. 裁剪某些区域(脉冲)并将它们每个保存到pd.DataFrame
  3. 全部保存DataFrames到一个hdf5文件中

这工作正常,但tables模块似乎NaturalNameWarning为每个单个DataFrame.

这是DataFrames保存到的位置hdf5

num = 0
for idx, row in df_oszi.iloc[peaks].iterrows():
    start_peak = idx - 1*1e-3
    end_peak = idx + 10*1e-3  #tges=11us
    df_pos = df_oszi[start_peak:end_peak]
    df_pos.to_hdf('pos.h5', key=str(num))
    num += 1
Run Code Online (Sandbox Code Playgroud)

输出:

Warning (from warnings module):
  File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\tables\path.py", line 157
    check_attribute_name(name)
NaturalNameWarning: object name is not a valid Python identifier: '185'; it does not match the pattern ``^[a-zA-Z_][a-zA-Z0-9_]*$``; you will …
Run Code Online (Sandbox Code Playgroud)

python hdf5 pandas

2
推荐指数
1
解决办法
4040
查看次数