python3模块在哪里?

时间:2017-11-26 11:38:10

标签: mysql python-3.x module mariadb

我正在尝试运行示例数据库连接我的mariadb数据库。

  python3 sample.py
  Traceback (most recent call last):
  File "sample.py", line 3, in <module>
    import mysql.connector as mariadb
ModuleNotFoundError: No module named 'mysql'

我已经安装了python3-mysql.connector。

sudo apt-get -y install python3-mysql.connector
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-mysql.connector is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

1 个答案:

答案 0 :(得分:0)

我建议使用pip来安装Python模块:

sudo pip3 install mysql-connector

然后您的Python程序应该可以使用该模块。