python错误求助

查看 87|回复 4
作者:zhoushao   
[color=]求助,运行如下代码,会报错误(如下)。其中result是三维数组,在其他电脑上运行正常
[color=]import
numpy
[color=]as
np
[color=]import
matplotlib.pyplot
[color=]as
plt
result=np.load(
[color=]'result.npy'
)
print
(result.shape)
result=result.reshape(
[color=]384000
,
[color=]1600
)
plt.figure(
dpi
=
[color=]300
,
figsize
=(
[color=]10
,
[color=]10
))
plt.imshow(result[
[color=]800
:
[color=]1600
,:].T,
cmap
=
[color=]"Set1"
,
aspect
=
[color=]'auto'
)
plt.colorbar().ax.set_title(
[color=]'class'
)
plt.xlabel(
[color=]'Trace number'
)
plt.ylabel(
[color=]'Time(ms)'
)
plt.show()
错误:Error: failed to send plot to http://127.0.0.1:63342Traceback (most recent call last):  File "C:\Program Files\JetBrains\PyCharm 2022.1\plugins\python\helpers\pycharm_display\datalore\display\display_.py", line 76, in _send_display_message    urllib_request.urlopen(url, buffer)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 214, in urlopen    return opener.open(url, data, timeout)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 523, in open    response = meth(req, response)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 632, in http_response    response = self.parent.error(  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 561, in error    return self._call_chain(*args)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 494, in _call_chain    result = func(*args)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 641, in http_error_default    raise HTTPError(req.full_url, code, msg, hdrs, fp)urllib.error.HTTPError: HTTP Error 500: Internal Server ErrorDuring handling of the above exception, another exception occurred:Traceback (most recent call last):  File "C:\Program Files\JetBrains\PyCharm 2022.1\plugins\python\helpers\pycharm_display\datalore\display\display_.py", line 60, in try_empty_proxy    urllib_request.urlopen(url, buffer)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 214, in urlopen    return opener.open(url, data, timeout)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 523, in open    response = meth(req, response)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 632, in http_response    response = self.parent.error(  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 561, in error    return self._call_chain(*args)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 494, in _call_chain    result = func(*args)  File "C:\Users\zhoushao\.conda\envs\pytorch11-py39\lib\urllib\request.py", line 641, in http_error_default    raise HTTPError(req.full_url, code, msg, hdrs, fp)urllib.error.HTTPError: HTTP Error 500: Internal Server ErrorProcess finished with exit code 0
[color=]

错误, 会报

shiyihu   

直接去pycharm的设置setting——>tools——>python scientific,然后取消勾选☑️Show plot in tool windosw.
再次运行你的代码,就能正常显示了。
zhoushao
OP
  


shiyihu 发表于 2023-3-17 16:53
直接去pycharm的设置setting——>tools——>python scientific,然后取消勾选☑️Show plot in t ...

不行哦,早就试过了
zhangtiechui   

这个错误是因为程序试图将图像发送到一个本地的Web服务器,但是出现了服务器错误。这并不会影响你的程序本身的运行。如果你想不显示这个错误,可以尝试在PyCharm中关闭自动打开浏览器的选项。具体方法如下:
1. 在PyCharm中打开Settings(或者Preferences)。
2. 在左侧的菜单栏中选择Tools,然后选择Python Scientific。
3. 在右侧的选项卡中,取消勾选Show plots in tool window和Show plots in browser的复选框。
4. 点击Apply或者OK保存设置。
这样设置之后,程序就不会自动在浏览器中打开图像,也就不会出现上述错误了。
zhoushao
OP
  


zhangtiechui 发表于 2023-3-17 17:14
这个错误是因为程序试图将图像发送到一个本地的Web服务器,但是出现了服务器错误。这并不会影响你的程序本 ...

不行哦,会提示QT啥的无法初始化,我还是不能看到这张图片
您需要登录后才可以回帖 登录 | 立即注册

返回顶部