gpt4 book ai didi

python - 导入 mysql.connector ImportError : No module named connector

转载 作者:太空狗 更新时间:2023-10-29 21:11:14 25 4
gpt4 key购买 nike

1) sudo dpkg -i mysql-connector-python_1.0.12-1ubuntu12.04_all.deb

2) sudo dpkg -i mysql-utilities_1.3.5-1debian6.0_all.deb

(Reading database ... 50871 files and directories currently installed.)
Preparing to replace mysql-utilities 1.3.5 (using mysql-utilities_1.3.5-1debian6.0_all.deb) ...
Unpacking replacement mysql-utilities ...
postrm script for mysql-utilities
foundpython2.7
/opt/bitnami/python/lib/python2.7/site-packages
Setting up mysql-utilities (1.3.5) ...
postinst script for mysql-utilities
python2.7
found
python2.7
/opt/bitnami/python/lib/python2.7/site-packages
Processing triggers for man-db ...

(工作时会提供参数)

3) 尝试运行 mysqlrplcheck:

$ mysqlrplcheck
Traceback (most recent call last):
File "./mysqlrplcheck", line 38, in <module>
from mysql.utilities.common.server import check_hostname_alias
File "/opt/bitnami/python/lib/python2.7/site-packages/mysql/utilities/common/server.py", line 29, in <module>
import mysql.connector
ImportError: No module named connector

它没有找到 mysql.connector。我该如何配置?

最佳答案

user2767144 通过编辑解决了问题:

/usr/local/lib/python2.7/dist-packages/mysql/__init__.py

并添加:

from pkgutil import extend_path
path = extend_path(path, name)

关于python - 导入 mysql.connector ImportError : No module named connector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18732275/

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