标签: user-warning

如何摆脱BeautifulSoup用户警告?

安装BeautifulSoup之后,每当我在cmd中运行我的Python时,就会出现这个警告.

D:\Application\python\lib\site-packages\beautifulsoup4-4.4.1-py3.4.egg\bs4\__init__.py:166:
UserWarning: No parser was explicitly specified, so I'm using the best
available HTML parser for this system ("html.parser"). This usually isn't a
problem, but if you run this code on another system, or in a different
virtual environment, it may use a different parser and behave differently.

To get rid of this warning, change this:

 BeautifulSoup([your markup])

to this:

 BeautifulSoup([your markup], "html.parser")
Run Code Online (Sandbox Code Playgroud)

我没有理解为什么它出来以及如何解决它.

python beautifulsoup user-warning

41
推荐指数
4
解决办法
5万
查看次数

msvc和gcc上的用户警告?

在MSVC中,我在标题中有这个:

#define STR(x)          #x
#define STR2(x)         STR(x)
#define NOTE(text)      message (__FILE__ "(" STR2(__LINE__) ") : -NOTE- " #text)
#define noteMacro(text) message (__FILE__ "(" STR2(__LINE__) ") : " STR2(text))
Run Code Online (Sandbox Code Playgroud)

而我呢

#pragma NOTE(my warning here)
Run Code Online (Sandbox Code Playgroud)

GCC有:

#warning(my warning here)
Run Code Online (Sandbox Code Playgroud)

然而,MSVC(2003)在看到#warning并发出"致命错误C1021:无效的预处理器命令'警告' 时抛出一个拟合"

我该怎么办?有没有办法让GCC认出MSVC警告或MSVC不会在GCC警告上抛出错误?我可以做些什么对两者都有效吗?我可以让GCC警告我关于未知的pragma,但这不是最理想的解决方案.

gcc user-warning visual-c++

15
推荐指数
2
解决办法
8252
查看次数

如何在 pytest 中断言 UserWarning 和 SystemExit

在 pytest 中断言 UserWarning 和 SystemExit

在我的应用程序中,我有一个函数,当提供错误的参数值时,它将UserWarningswarnings模块引发,然后SystemExitsys模块引发。

代码是这样的:

def compare_tags(.....):

    requested_tags = user_requested_tags # as list
    all_tags = tags_calculated_from_input_file  # as list 

    non_matching_key = [x for x in requested_tags if x not in all_tags]

    # if user requested non existing tag then raise warning and then exit 
    if len(non_matching_key) > 0:

        # generate warning
        warnings.warn("The requested '%s' keys from '%s' is not present in the input file. Please makes sure the input …
Run Code Online (Sandbox Code Playgroud)

python unit-testing systemexit user-warning pytest

8
推荐指数
1
解决办法
1491
查看次数

torch meshgrid 警告:在即将发布的版本中,将需要传递索引参数

我正在尝试执行 LIIF( https://github.com/yinboc/liif ​​) 并出现以下警告:

/usr/local/lib/python3.7/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2157.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Run Code Online (Sandbox Code Playgroud)

python grid user-warning torch pytorch

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

Python 2.7 Openpyxl用户警告

为什么每次运行代码时都收到此警告消息?(下面)。有可能摆脱它吗?如果是这样,我该怎么做?

我的代码:

from openpyxl import load_workbook
from openpyxl import Workbook

wb = load_workbook('NFL.xlsx', data_only = True)
ws = wb.active
sh = wb["Sheet1"]


ptsDiff = (sh['J127'].value)
print ptsDiff
Run Code Online (Sandbox Code Playgroud)

该代码有效,但我收到此警告消息:

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/openpyxl/reader/worksheet.py", line 320
warn(msg)
UserWarning: Unknown extension is not supported and will be removed
Run Code Online (Sandbox Code Playgroud)

python warnings user-warning python-2.7 openpyxl

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

用户警告:对已关闭的文件调用 close()。warn("在已经关闭的文件上调用 close()。")

此错误显然源于 xlsxwriter。我不确定它来自我的代码的哪一行,因为每次我尝试调试时,我的编辑器 Visual Studio 2019 都会崩溃。但是,我在使用 VPN 和远程桌面连接时在笔记本电脑上收到此错误。如果我从远程机器运行相同的代码,则不会出现错误。不过,该错误似乎不会影响输出,因为脚本已成功完成并保存。但是,我该如何摆脱这个错误?

我的代码:

import requests
from bs4 import BeautifulSoup
import pandas as pd
from pandas import ExcelWriter
from datetime import datetime
import os

#set the headers as a browser
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
#set up file name
file_path = r"C:\Users\jpilbeam"
excel_file = 'bargetraffic' + str(datetime.now().strftime('_%m_%d_%Y')) + '.xlsx'
excel_file_full = os.path.join(file_path, excel_file)

lockName = ['Dresden Island Lock', 'Brandon Rd Lock', 'Lockport Lock']
lockNo …
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup user-warning pandas xlsxwriter

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

二阶ODE dopri5 python UserWarning:较大的nmax

对于二阶ODE(Python中的dopri5方法),以下代码始终会导致错误:C:\Users\MY\Anaconda3\lib\site-packages\scipy\integrate\_ode.py:1019: UserWarning: dopri5: larger nmax is needed self.messages.get(idid, 'Unexpected idid=%s' % idid))。我更改了参数,但似乎无济于事。即使设置nsteps=100000也不起作用。还有其他方法可以解决这个问题,而不仅仅是增加nsteps

from scipy.integrate import ode
import numpy as np

def fun(t, y):
    return np.array([y[1], -3/t*y[1] + 7/(t**6)*y[0]])

yinit = np.array([0.01, 0.2])

dt = 0.01
t_stop = 2

solver = ode(fun).set_integrator('dopri5', nsteps=100000).set_initial_value(yinit)
solver.t = 0.001
t_RK4_sci = [0]
x_RK4_sci = [yinit]
while solver.successful() and solver.t < t_stop:
    solver.integrate(solver.t+dt, step=True)
    t_RK4_sci.append(solver.t)
    x_RK4_sci.append(solver.y)
t_RK4_sci = np.array(t_RK4_sci)
x_RK4_sci = np.array(x_RK4_sci)
Run Code Online (Sandbox Code Playgroud)

python scipy user-warning ode

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

userWarning pymc3:重新参数化是什么意思?

我使用 DensityDist 分布构建了一个 pymc3 模型。我有四个参数,其中 3 个使用 Metropolis,一个使用 NUTS(这是由 pymc3 自动选择的)。但是,我得到两个不同的 UserWarnings 1.Chain 0 在调整后包含发散样本的数量。如果增加target_accept无济于事,请尝试重新参数化。我可以知道这里重新参数化是什么意思吗?2.链0中的接受概率与目标不匹配。它是 ,但应该接近 0.8。尝试增加调整步骤的数量。

通过一些例子,我使用了“random_seed”、“discard_tuned_samples”、“step = pm.NUTS(target_accept=0.95)”等等,并摆脱了这些用户警告。但是我找不到有关如何确定这些参数值的详细信息。我相信这可能已经在各种上下文中讨论过,但我无法找到可靠的文档。我正在做一个试错法,如下所示。

with patten_study: #SEED = 61290425 #51290425 step = pm.NUTS(target_accept=0.95) trace = sample(step = step)#4000,tune = 10000,step =step,discard_tuned_samples=False)#,random_seed=SEED)

我需要在不同的数据集上运行这些。因此,我正在努力为我使用的每个数据集修复这些参数值。有什么方法可以让我给出这些值或找到结果(如果有任何用户警告,然后尝试其他值)并在循环中运行它?

如果我问一些愚蠢的事情,请原谅我!

user-warning pymc3

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