error: package directory 'argparse' does not exist - python

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.

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.

Related

the compiled code path to the location of the error is shown and not the executable path

I searched a lot about this problem although there are many trials of other people but this problem I couldn't find or may be I am using wrong terms while searching.
I am using this method to create an executable for my python code. Everything runs fine but when I run the code and there is an error. The path to the file where the error took place is relative to the compiled code and not the executable. I was expecting to refer paths where the files are currently in the executable but not to show the paths where the code was compiled.
setup.py
build_exe_options = {
"optimize": 0,
"excludes": ["PyQt6"]}
pkgs = find_namespace_packages(include=["controller*", "model*", "Resources*", "view*", "DLL*"])
setup(name='myApp',
version='0.0',
packages=pkgs,
install_requires=[
'numpy',
"scipy"
],
include_package_data=True,
options={"build_exe": build_exe_options},
executables= Executable("app.py", base=None)
The Commands
python -m venv venv
venv\Scripts\activate
python.exe -m pip install --upgrade pip
pip install cx_freeze setuptools
pip install -e .
python setup.py build_exe
Is there something I am missing while creating the executable?
I found a solution by trial and error. I had to add in setup.py in options
"replace_paths": [("*", "")]
The solution was shown in enter link description here
now I have the path to error starting by the folder of the compiled source code
Before: user/Desktop/projectFolder/..../something.py
Now: projectFolder/..../something.py
Which what I wanted exactly.

Pyinstaller Files Suddenly Missing

I successfully created .exe files using Pyinstaller. I was on a Windows 7 machine using Anaconda3, PyQt5, OpenCV3, and Python 3.6. Anaconda3 was in the Windows Environment Path. Because there is no release for Pyinstaller for Python 3.6, I created a Python 3.5.3 environment (with OpenCV) within Anaconda3. I wrote the software in Python 3.6, then activated Python3.5.3 to run Pyinstaller. The executable worked flawlessly. The dist folder was abot 370MB.
Then I upgraded the machine to Windows 10 using a clean installation. I installed Anaconda3 (Anaconda3 was added to the Windows Environment Path) and OpenCV (PyQt5 was already available within Anaconda3), created the Python3.5.3 environment, installed PyInstaller iand OpenCV nto the Python 3.5.3 environment. Using Spyder and Python 3.6, the script runs perfectly. When activating Python 3.5.3 and running python myscript.py from the command line, the script ran flawlessly. However, Pyinstaller only installs about 220MB and the resultant executable does not execute.
I don’t have the old dist folder from the successful Windows 7 build to see what files were added to the dist folder that were not added when in Windows 10.
Does anyone know how I can determine the additional files needed for the Pyinstaller buid?
I switched to cx_Freeze. It also didn't work at first, but then I added optional packages PyQt5, cv2, and numpy. cx_Freeze crashed and gave me an error about PyQt5, so I took PyQt5 out of the optional packages and ran python setup.py build again and it worked. So then I removed cv2 and it still worked. Then I removed numpy and it failed. So I added numpy back in. Here is setup.py
from cx_Freeze import setup, Executable
exe=Executable(
script="VSWv08.py", base = "Win32GUI")
includefiles=["VSWManual.txt", "VSWLicense.txt"]
includes=[]
excludes=[]
packages=["numpy"]
setup(
version = "1.0",
description = "MyApplication",
author = "Me",
name = "My Application",
options = {'build_exe':
{'excludes':excludes,'packages':packages,'include_files':includefiles}},
executables = [exe]
)

Python setup.py doesn't install to virtualenv

I'm trying to get the hang of developing distributable Python packages. I have a simple setup.py script that looks like this:
from distutils.core import setup
setup(
name='foo',
version='1.0',
py_modules=['foo'],
)
If I activate the virtualenv for this project and run setup.py develop it installs to my global site-packages -- not the virtualenv. If I pass in the env's site package directory using --install-dir, it gives the error
error: bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
C:\Users\men\Envs\foo\Lib\site-packages
Isn't the venv's activate script supposed to set this up?

Installing Python Module to non-root directory

First time posting on this site.
I'm trying to install a python module named Pygments into my local directory at work (non-root). I am using C Shell, so i changed default path using
setenv PYTHONPATH "~/usr/lib/python2.4/site-packages:${PYTHONPATH}"
(with usr/lib/... being self-made empty directories made to mimic the system's hierarchy at my boss's suggestion). I attempted to run
python setup.py install
however, I got the following error.
/usr/lib64/python2.4/distutils/dist.py:236: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
/usr/lib64/python2.4/distutils/dist.py:236: UserWarning: Unknown distribution option: 'include_package_data'
warnings.warn(msg)
running install
running build
running build_py
running build_scripts
running install_lib
creating /usr/local/lib64
error: could not create '/usr/local/lib64': Read-only file system
I want the module to install to my local directory and not to any root directory. I've been stuck on this for a couple of days. Any help would be greatly appreciated.
Colten
Extra Information: I have setup.py in ~/Pygments-1.6, and I only have write access to directories within ~/.
PYTHONPATH is where python looks for modules, not where it chooses to install modules. You need to specify that on the setup.py line:
python setup.py install --prefix=${HOME}/usr/
or something similar. Another thing that you'll see in these cases is:
python setup.py install --user
which will put it in: '${HOME}/.local/lib/pythonX.Y/site-packages' (And I believe that this path should be searched by python for modules by default.)

Can not install hcluster from pypi under python 2.6 on xp

I am using the setup.py file supplied with hcluster with the following lines added:
sys.path.append("c:\\Program Files\\Python26\\Lib\\site-packages\\hcluster-0.2.0")
sys.path.append("c:\\Program Files\\Python26\\Lib\\site-packages\\hcluster-0.2.0\\hcluster")
Then used setup.py as follows:
"c:\program files\python26\python.exe" "c:\Program Files\Python26\Lib\site-packages\hcluster-0.2.0\setup.py" install
I get the following error messages:
running install
running build
running build_py
error: package directory 'hcluster' does not exist
Don't know if it trying to read or write hcluster.
Any help appreciated
You don't need to add packages in site-packages in sys.path.
Did you copy the hcluster in site-package manually? It is not the correct way to do it.
2.1 You should have the hcluster outside the site-packages say in your home directory and then run "python setup.py install"
2.2 This will put the package after build into site-package directory. This is where all external package reside by default after they are installed.
Remove the folders related to hcluster from site-packages and install with instruction 2.
Read the following to understand your error: http://docs.python.org/install/index.html

Categories

Resources