【发布时间】:2020-04-22 02:49:09
【问题描述】:
我在尝试连接到我的 dB 时收到此错误:
~/anaconda3_420/lib/python3.5/site-packages/pymysql/__init__.py in Connect(*args, **kwargs)
88 """
89 from .connections import Connection
---> 90 return Connection(*args, **kwargs)
91
92 from pymysql import connections as _orig_conn
~/anaconda3_420/lib/python3.5/site-packages/pymysql/connections.py in __init__(self, host, user, password, database, port, unix_socket, charset, sql_mode, read_default_file, conv, use_unicode, client_flag, cursorclass, init_command, connect_timeout, ssl, read_default_group, compress, named_pipe, no_delay, autocommit, db, passwd, local_infile, max_allowed_packet, defer_connect, auth_plugin_map, read_timeout, write_timeout)
686 self._sock = None
687 else:
--> 688 self.connect()
689
690 def _create_ssl_ctx(self, sslp):
~/anaconda3_420/lib/python3.5/site-packages/pymysql/connections.py in connect(self, sock)
903 self._next_seq_id = 0
904
--> 905 self._get_server_information()
906 self._request_authentication()
907
~/anaconda3_420/lib/python3.5/site-packages/pymysql/connections.py in _get_server_information(self)
1229 i += 6
1230 self.server_language = lang
-> 1231 self.server_charset = charset_by_id(lang).name
1232
1233 self.server_status = stat
~/anaconda3_420/lib/python3.5/site-packages/pymysql/charset.py in by_id(self, id)
36
37 def by_id(self, id):
---> 38 return self._by_id[id]
39
40 def by_name(self, name):
KeyError: 255
我在这篇帖子Error Keyerror 255 when executing pymysql.connect 中读到,可以通过更改此文件pymysql.__file__ 轻松解决问题。
但是除了这个在第 143 行结束的文件(在引发异常的 1268 处插入)之外,我只能在 python 中读取该文件,但不能访问它,因为它不是本地的。我也没有找到pip升级pymysql的方法。
编辑: 我刚刚在 azure 上找到了一个终端,但我的许可被拒绝了。有什么我可以做的吗?
nbuser@nbserver:~$ pip install --upgrade pymysql
Collecting pymysql
Using cached https://files.pythonhosted.org/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/PyMySQL-0.9.3-py2.py3-none-any.whl
Installing collected packages: pymysql
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/dist-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/usr/local/lib/python3.5/dist-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/PyMySQL-0.9.3.dist-info'
You are using pip version 9.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
【问题讨论】:
标签: python azure pymysql keyerror