首页 > 解决方案 > Python-Django 导入 csv 到 Jupiter 注意本地

问题描述

嗨,我在 Django 应用程序中创建导出 csv 文件,接下来我将其导入 Jupiter,当我的 Django 在线发布时一切正常,但是当我的项目在本地运行时无法导入,如http://127.0.0.1:8000/

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

import io
import requests
import urllib.request as urllib2
df = pd.read_csv('http://127.0.0.1:8000/covid/covid.csv/')
df.head(100)

    ConnectionRefusedError                    Traceback (most recent call last)
/usr/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1349                 h.request(req.get_method(), req.selector, req.data, headers,
-> 1350                           encode_chunked=req.has_header('Transfer-encoding'))
   1351             except OSError as err: # timeout error

18 frames
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
/usr/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1350                           encode_chunked=req.has_header('Transfer-encoding'))
   1351             except OSError as err: # timeout error
-> 1352                 raise URLError(err)
   1353             r = h.getresponse()
   1354         except:

URLError: <urlopen error [Errno 111] Connection refused>

有任何想法吗?

标签: pythondjangocsv

解决方案


推荐阅读