Domanda

I can't figure out how to use py2exe, what am I doing wrong?

This is my my setup.py file witch is in the same folder as the rest of my project:

from distutils.core import setup
import py2exe

setup(console=['main.py'])

And then, as described on the homepage of py2exe, I navigate to the project directory with my python-files and type

python setup.py py2exe

But I only get this error!

E:\Programme(x86)\Python2.7x86\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'console'
  warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'py2exe'

I've seen and read this post and lot's of others, but all seem to solve the problem by:

  • installing py2exe
  • navigating to the source path
  • typing in the correct command
  • correcting setup.py

All this (seems to me) is correct in my case. Maybe the solution is written in the error, but I can't interpret it usefully...

Other things I tried:

  • Use absolute paths
  • python setup.py py2exe install

I recognized that the problem occurs while importing py2exe, python doesn't execute anything after the second line.

Note: The PATH variable is correctly set, typing "python" and then "import py2exe" into the cmd works fine.

Thanks!

È stato utile?

Soluzione

With the help of g.d.d.c I found the problem.

There was a "py2exe.pyc" in the same directory witch confused the python-interpreter. Besides I did not know there was a file with this name, I also didn't know you can import and use them like modules...

If your problem stays, test if it works after re-installing Python.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top