4

I'm trying to use py2exe and right now I'm just having trouble building the samples and tutorials that come with py2exe. I run setup.py and that goes fine but when I try to run the exe that is created I get the "LoadLibrary(pythondll) failed" error. I haven't moved the exe from the dist directory and I see that python27.dll is in that dist directory. Does anyone know what might be happening?

In case it matters I'm running 32 bit python 2.7 with the corresponding 32 bit python 2.7 py2exe on windows 7.

Thanks

The test.py file just contains print "test"

Here's my setup.py based off what Kirk wrote:

from distutils.core import setup
import py2exe
import sys
from glob import glob
project_folder = r'C:\\Python27\\Lib\site-packages\\py2exe\\samples\\test\\'
data_files = [
 ("dlls", glob(project_folder + r'dlls\\*.dll')) 
 ,("pyds", glob(project_folder + r'pyds\\*.pyd')) 
 ]
options = { }
setup(
name='test'
,options = options
,zipfile = None
,data_files=data_files
,console=['test.py']
)
asked Jul 25, 2011 at 17:38
0

2 Answers 2

1

You'll want to specifically include the python27.dll file. If you're including multiple things, use glob and a data files array like below to get the best results with py2exe. For this example, create a Dll folder and put python27.dll in there.

from distutils.core import setup
import py2exe
import sys
from glob import glob
data_files = [
 ("Stuff", glob(r'C:\projectfolder\Stuff\*.*')) 
 ,("dlls", glob(r'C:\projectfolder\dlls\*.dll')) 
 ,("pyds", glob(r'C:\projectfolder\pyds\*.pyd')) 
 ]
options = { }
setup(
name='ProjectName'
,options = options
,zipfile = None
,data_files=data_files
,console=['projectname.py']
)
answered Jul 26, 2011 at 20:37
Sign up to request clarification or add additional context in comments.

2 Comments

hmm I'm still getting the same error, @joaquin I edited my original post to show my setup.py based off what Kirk wrote
@Anshu That's because your project folder is invalid. Either use r'\', '\\', '/' or simply os.path.join (you may also want to use just os.path.dirname(__file__), which allows you to move the project to a different folder.
1

I know this is a pretty old question, but I had a similar problem. I had uninstalled python and py2exe 64 bit to replace it with the 32 bit version. After I did this, I always got this error. Later, I deleted my dist and build directories from my project, and the subsequent build worked.

answered Jun 6, 2018 at 14:26

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.