gpt4 book ai didi

python - docker/matplotlib : RuntimeError: Invalid DISPLAY variable

转载 作者:太空宇宙 更新时间:2023-11-04 00:47:31 24 4
gpt4 key购买 nike

我尝试了很多解决方法,但没有一个有效。

我试过 echo $DISPLAY 不工作

错误信息:

Environment:

Request Method: GET Request URL: http://10.231.xx.xx:8000/upload/

Traceback:

File "/opt/conda/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 149. response = self.process_exception_by_middleware(e, request)

File "/opt/conda/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 147. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/code/fileUpload_app/views.py" in msa_result 174. result1 = generate_hist(db, **processing_dict)

File "/code/fileUpload_app/post_processing.py" in generate_hist 182. fig1 = plt.figure()

File "/opt/conda/lib/python2.7/site-packages/matplotlib/pyplot.py" in figure 527. **kwargs)

File "/opt/conda/lib/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py" in new_figure_manager 46. return new_figure_manager_given_figure(num, thisFig)

File "/opt/conda/lib/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py" in new_figure_manager_given_figure 53. canvas = FigureCanvasQTAgg(figure)

File "/opt/conda/lib/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py" in init 76. FigureCanvasQT.init(self, figure)

File "/opt/conda/lib/python2.7/site-packages/matplotlib/backends/backend_qt4.py" in init 68. _create_qApp()

File "/opt/conda/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py" in _create_qApp 138. raise RuntimeError('Invalid DISPLAY variable')

Exception Type: RuntimeError at /upload/msa_result/1/ Exception Value: Invalid DISPLAY variable

我正在使用 docker 来托管我的网络项目。

我的代码包括这些:

import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt

def generate_hist(db, **kwargs):


fig1 = plt.figure()

hist = mat2[0, 0:pin_num]

fig1 = plt.hist(hist)

plt.savefig("fileUpload_app/static/img/result/hist.jpg")

最佳答案

原因是我在import matplotlib之前import seaborn。这导致 matplotlib 没有在正确的地方运行。

关于python - docker/matplotlib : RuntimeError: Invalid DISPLAY variable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38776267/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com