error: [Errno 2] Python3 - python-3.x

I'm trying to convert a py file to a .exe using cx_Freeze. I used Python 3.6 to made the program and I'm using a Mac.
I've watched many tutorials on YouTube and I understand I have to create a file named setup.py with the following code:
from cx_Freeze import setup, Executable
setup(name='program',
version='0.1',
description = 'program for mun',
executables = [Executable('main.py')]
)
And then when in Terminal I must enter:
python3 setup.py build
After some seconds it shows the following error:
error: [Errno 2] No such file or directory: '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl'
Does anyone know why? Thanks.

Related

I'm unable to create the .exe for the most simple 'hello world' example

I've used py2exe successfully for previous projects on previous build machines, but now I've freshly installed everything from scratch and can't run the simplest example:
setup.py:
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
hello.py:
print("Hello World")
Command: python3 setup.py py2exe
Output:
running py2exe
1 missing Modules
------------------
? _posixshmem imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
Building 'dist\hello.exe'.
error: [WinError 87] The parameter is incorrect.
dest\hello.exe is generated (37 kB!) but gives the following error when run:
Could not locate script resource:The specified resource type cannot be found in the image file.
FATAL ERROR: Could not locate script
The versions I have installed are:
python --version
Python 3.8.6
pip freeze
cachetools==4.1.1
future==0.18.2
numpy==1.19.3
opencv-python==4.4.0.46
pefile==2019.4.18
py2exe==0.10.1.0
pyreadline==2.1
pywin32==300
systeminfo
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.19041 N/A Build 19041
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Hotfix(s): 6 Hotfix(s) Installed.
[01]: KB4580419
[02]: KB4561600
[03]: KB4577266
[04]: KB4580325
[05]: KB4586864
[06]: KB4586781
Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
I know that there is clearly something weird happening (I've already hit the issue with 'numpy' here: https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html ) ... but I can't quite see what it is.
Thanks !
-- Mac
You just misstyped the command line flag, should be: python setup.py py2exe.
Works fine for me on Win7, Python 3.8.0:
(py38) λ python setup.py py2exe
running py2exe
2 missing Modules
------------------
? _posixshmem imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
? readline imported from cmd, code, pdb
Building 'dist\hello.exe'.
Building shared code archive 'dist\library.zip'.
Copy c:\users\f3k\envs\py38\scripts\python38.dll to dist
...
Copy DLL C:\Python38\DLLs\libffi-7.dll to dist\
C:\temp
(py38) λ dist\hello.exe
Hello World

using cx_freeze in spyder

I installed cx_Freeze using pip:
C:\Users\Sarah\Documents\PythonScripts>python -m pip install cx_Freeze --upgrade
Collecting cx_Freeze
Downloading cx_Freeze-5.0.2-cp36-cp36m-win_amd64.whl (162kB)
Installing collected packages: cx-Freeze
Successfully installed cx-Freeze-5.0.2
However, I get this error when I try to execute a script:
setup.py build
Traceback (most recent call last):
File "C:\Users\Sarah\Documents\PythonScripts\setup.py", line 9, in <module>
from cx_freeze import setup, Executable
ImportError: No module named cx_freeze
When I check the system path, I get all this information
print (sys.path)
['', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\spyder\\utils\\site', 'C:\\Users\\Sarah\\Documents\\PythonScripts', 'C:\\Users\\Sarah\\Anaconda3\\python36.zip', 'C:\\Users\\Sarah\\Anaconda3\\DLLs', 'C:\\Users\\Sarah\\Anaconda3\\lib', 'C:\\Users\\Sarah\\Anaconda3', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Pythonwin', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\Sarah\\.ipython']
I am assuming that somehow, the path to the cx_freeze module is lost in here somewhere. I would really appreciate some simple (novice user) ideas for how to go about fixing this.
I tried copying the folder cx-freeze to the PythonScripts folder but that didn't help.
I know why you are getting this error and I do not think it has anything to do with the file path.
Try:
from cx_Freeze import setup, Executable
in the place of
from cx_freeze import setup, Executable
in your setup.py script
and this error should fix (you had f not F).

Py2exe for Python 3.5.2 not working

C:\Users\Other\Desktop\DoA-Tools>python "C:/Users/Other/Desktop/DoA-Tools/convert doa-tools.py" py2exe
running py2exe
1 missing Modules
------------------
? readline imported from cmd, code, pdb
Building 'dist\DoA-Tools.exe'.
error: [Errno 2] No such file or directory: 'C:\\Users\\Other\\Desktop\\Python3.5.2\\lib\\site-packages\\py2exe\\run-py3.5-win32.exe'
I downloaded py2exe (pip install py2exe), and Im using Python 3.5.2. I have a script that I need to be an executable file, but I keep getting the above error when I try python <filename> py2exe. Any ideas? I tried to remove and redownload, but that didn't work

py2exe No such file or directory

I am following the tutorial here and when I try to run setup.py I get this
running py2exe
Building 'dist\test.exe'.
error: [Errno 2] No such file or directory: 'C:\\Anaconda3\\lib\\site-packages\\py2exe\\run-py3.5-win-amd64.exe'
What am I doing wrong?
What is your python version? py2exe does not support Python 3.5, but you can use Python 3.4 or lower.

Building minimal cython file with python 3.3 (Anaconda) under windows 7

When I try to build a minimal Cython file test.pyx with Python 3.3 (Anaconda 3) under windows 7, I obtain a strange error:
C:\Users\myname\Test_cython>python setup.py build
running build
running build_ext
error: [WinError 2] The system cannot find the file specified
Of course test.pyx is in the working directory. It works fine under windows with Python 2.7 (Anaconda) and under Linux with Python 2 and 3.
What could be the problem here with Python 3.3 (Anaconda 3)?
Thanks
The file setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
name = 'test',
cmdclass = {"build_ext": build_ext},
ext_modules = [Extension('test', ['test.pyx'])]
)
Solution:
I found that the line 404 of the file cygwinccompiler.py of the package disutils
out_string = check_output(['gcc', '-dumpmachine'])
has to be changed as
out_string = check_output(['gcc', '-dumpmachine'], shell=True)
Then, it compiles normally.
The line 404 of the file cygwinccompiler.py of the package disutils
out_string = check_output(['gcc', '-dumpmachine'])
has to be changed as
out_string = check_output(['gcc', '-dumpmachine'], shell=True)
Then, it compiles normally.

Resources