Home > Net >  No module named 'mysql'
No module named 'mysql'

Time:01-17

I have created Python script to store data in MySQL, when I run script on PyCharm it's working properly, but when I convert it to .exe file script does not do anything and this is the respond I get on Command Prompt:

Traceback (most recent call last):
  File "myscript.py", line 1, in <module>
    import mysql.connector
ModuleNotFoundError: No module named 'mysql'
[8428] Failed to execute script 'myscript' due to unhandled exception!

The command I am using:

pyinstaller --onefile --console CoinVolumes.py

I tried aswell on auto-py-to-exe but get same error. Mysql is installed

I have been trying to find solution whole day, but can't, please help me!

CodePudding user response:

In Python 3.6.9 I can use Pip 3 and do following:

pip3 install mysql
pip3 install mysql-connector-python

CodePudding user response:

use this command:

pip install mysql-connector-python

after that verify:

$ python
Python 2.7.11 (default, Apr 26 2016, 13:18:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>>

CodePudding user response:

You would need to run the mysql server yourself. Pyinstaller is working properly, the problem here is that mysql server is not part of python, therefore you need to start the server mannualy. An alternative is to use sqlite, which does not require a server. It is built into standard python, no need for installing anything.

  •  Tags:  
  • Related