Update: This seems to be connected specifically to the an issue with pyinstaller freezing the socket package. Running the following code is fine in python, but after freezing to an exe with pyinstaller it gives the OSError.
import socket
try:
socket.socket()
except OSError as e:
print(e)
Original text:
I'm currently trying to build a python script that queries a mySQL database using mysql.connector. Running the code in python works fine, but when I freeze it using pyinstaller and run the exe I get an OSError: [WinError 10022] An invalid argument was supplied
when it tries to run the mysql.connector.connect
function.
My code is below:
import mysql.connector
def test(user, password, ip, query):
con = mysql.connector.connect(user=user,
password=password,
host=ip)
cursor = con.cursor()
cursor.execute(query)
rows = cursor.fetchall()
cursor.close()
con.close()
return rows
The full error text is:
Traceback (most recent call last):
File "site-packages\mysql\connector\network.py", line 507, in open_connection
File "socket.py", line 134 in __init__
OSError: [WinError 10022] An invalid argument was supplied
Looking around, the only mysql.connector questions related to pyinstaller I can find are due to import errors while the WinError 10022 questions seem to be about other packages.