Question

I am attempting to compile an executable for my python script using cxFreeze. Out of the many libraries which I need to import for my script, two seem to fail with cxFreeze. In particular, consider the following test.py script:

print('matplotlib.pyplot')
import matplotlib.pyplot

compiling this with cxFreeze and running gives the following output:

matplotlib cxFreeze problem

separately, the following test.py script:

print('BeautifulSoup from bs4')
from bs4 import BeautifulSoup

after being compiled with cxFreeze, produces the following output: BeautifulSoup cxFreeze problem

My setup.py file for cxFreeze looks as follows:

import sys
from cx_Freeze import setup, Executable

setup(
    name = "myname",
    version = "1.0",
    description = "some description",
    executables = [Executable("test.py", base = None)]    
)

I am running Python 3.3 x86, and am using a 32 bit version of cxFreeze (most recent) on Windows 7.

I am having trouble chasing down this issue. For one, the directory "C:\Python\32-bit..." doesn't exist on my computer, so I am unclear as to why cxFreeze is trying to look there. Does anyone have any idea how to approach this, or perhaps has already dealt with this issue?

Était-ce utile?

La solution

After some digging around, I was able to resolve the issue. For those who may be encountering the same issue, this is what solved it for me:

For the issue with matplotlib: I simply needed to explicitly specify to cxFreeze to include matplotlib.backends.backend_tkagg. My setup file ended up looking like this:

import sys
from cx_Freeze import setup, Executable
packages = ['matplotlib.backends.backend_tkagg']

setup(
    name = "myname",
    version = "1.0",
    description = "some description",
    options = {'build_exe': {'packages':packages}},
    executables = [Executable("test.py", base = None)]    
)

As for the BeautifulSoup issue: There are a couple of posts around the web that have dealt with this issue: cx_freeze sre_constants.error nothing to repeat, https://bitbucket.org/anthony_tuininga/cx_freeze/issue/59/sre_constantserror-nothing-to-repeat. The relevant conclusion: something is wrong with the 4.3.2 build of cxFreeze that causes this issue. I simply used cxFreeze 4.3.1 to build my app and the problem was solved. It may also be possible to rebuild 4.3.2 locally and have the issue be resolved, but I did not attempt this solution.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top