我正在使用Python V3.6和Django V2.1创建示例应用程序,以前我遇到过与MySQL客户端有关的问题,因此我通过使用“ $.get('/getData', function( pythonResponse ){
d3.csvParse(pythonResponse, function(d){
var longitudes = [],
latitudes = [];
for (var i = -179.75; i < 180.0; i+=0.5){
longitudes.push(i);
}
for (var j = -89.75; j < 90.0; j+=0.5){
latitudes.push(j);
}
var data = [{
type:'scattergeo',
lon: longitudes,
lat: latitudes,
text: +d,
mode: 'markers',
...
Plotly.plot('div', data, layout, {showLink: false});
});
});
”修复了该问题,有助于安装 mysqlclient 成功,但是后来当我尝试运行应用程序时,出现以下错误。
pip install "mysqlclient==1.3.12
Setting.py
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000000003A93C80>
Traceback (most recent call last):
File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 2
16, in ensure_connection
self.connect()
File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 1
94, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\mysql\base.py", line
227, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\__init__.py", line 86, in Connec
t
return Connection(*args, **kwargs)
File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\connections.py", line 204, in __
init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'ODBC'@'localhost' (using password: NO)")
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\IPython\core\history.py", line 780, in w
riteout_cache
self._writeout_input_cache(conn)
File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\IPython\core\history.py", line 764, in _
writeout_input_cache
(self.session_number,)+line)
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was crea
ted in thread id 1776 and this is thread id 10192
如果我尝试使用默认数据库(sqlite3),则可以正常工作,但是当我尝试将其更改为 Mysql 时,出现此错误。
答案 0 :(得分:0)
确保提供了有效的凭据并安装了最新的mysqlclient。要安装mysqlclient,请使用命令pip install -I mysqlclient
。