Search code examples
pythonbuildexecutableargparse

error: package directory 'argparse' does not exist


I need to build an executable Python scripts. So I run "python setup.py build" , the error message shows in the below :

running build running build_py error: package directory 'argparse' does not exist

In my setup.py, below are the codes:

from cx_Freeze import setup, Executable

executables = [Executable("word_search_puzzle.py")]

setup(
    name = "Word Search Puzzle",
    version = "0.1",
    description = "A Word Search Puzzle Generator",
    executables = executables,
    packages = ['argparse']
)

So I have tried, installed/reinstalled argparse. I have tried rebooting my computer as well. I checked my Python version is 3.11.1 which should have included the argparse. My scripts are perfectly fine. I am not sure what else to be done.


Solution

  • The packages variable in setup() is for compiling your own packages from a code directory, not for installing packages. You don't need to include it when building an executable, simply having the package installed from pip should be enough.