hch
hch

Reputation: 198

pyinstaller importError: No module name '_socket'

I am using:

The code is:

import socket

print("test")
so = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
so.setblocking(True)  
print(so)

I launch pyinstaller like this

pyinstaller --noupx -D --log-level DEBUG test.py

And when I launch the executable i get the following:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
  File "c:\python35-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
    exec(bytecode, module.__dict__)
  File "socket.py", line 49, in <module>
ImportError: No module named '_socket'
Failed to execute script test

The warning file warntest.txt look like this (I have shortened it)

[...]
missing module named math.cos - imported by math, random, D:\Projet\eq_sim\test.py
missing module named socket.SOCK_STREAM - imported by socket, ssl, D:\Projet\eq_sim\test.py
missing module named socket.AF_INET - imported by socket, ssl, D:\Projet\eq_sim\test.py
missing module named socket.SO_TYPE - imported by socket, ssl, D:\Projet\eq_sim\test.py
missing module named socket.SOL_SOCKET - imported by socket, ssl, D:\Projet\eq_sim\test.py
missing module named copy.deepcopy - imported by copy, weakref, email.generator, D:\Projet\eq_sim\test.py
[...]

I have check the page https://github.com/pyinstaller/pyinstaller/wiki/If-Things-Go-Wrong to find out my issue but no success.

I have check the archive file out00-PYZ.pyz, it seems ok

In the directory [...]bincache00_py35_32bit/ the file _socket.pyd is present so it seems to find it.

I have tried adding paths (-p) and others stuff, the result is always the same

It is a pretty simple case, so I think I am missing something here

Upvotes: 6

Views: 6955

Answers (1)

hch
hch

Reputation: 198

Ok guys... I am ashamed ... I was not running the good executable file.

I was running the exe file in the build/ directory, I had to run the one in the dist/ directory.

Upvotes: 9

Related Questions