0

Using py2exe I create an exe version of my script with instructions I found here. The script compiles well and generates a dist and build folder each but when I run the program on the command line it gives this error. N.B the script works fine on my IDE environment, however I intend give a colleague the exe version.How can I fix this error?

Traceback (most recent call last):
  File "tester2.py", line 4, in <module>
ImportError: No module named mechanize

here is the setup.py file:

from distutils.core import setup
import py2exe

setup(

    console = ['tester2.py'],
    zipfile = None,
)
Community
  • 1
  • 1
Nobi
  • 1,063
  • 2
  • 25
  • 39

2 Answers2

0

You have to declare your dependencies. This is my setup

setup(
    executables=executables,
    options=options,
    name='bla',
    version='0.3',
    packages=[...],
    url='',
    license='',
    author='',
    author_email='',
    description='', requires=['pandas', 'unidecode', 'click',
                              'xlsxwriter'] // you would have to add mechanize here
)
Christian Sauer
  • 9,530
  • 9
  • 50
  • 76
0

Have you added files to the build?

Pls have a look at include option in setup.py: exe built with cx_Freeze, PyQt5, Python3 can't import ExtensionLoader_PyQt5_QtWidgets.py and run

Also here's my solution to similar problem, how to add files to build and run them later: Python - create an EXE that runs code as written, not as it was when compiled

Community
  • 1
  • 1
Eugene Lisitsky
  • 11,103
  • 4
  • 33
  • 56