Python Forum
Python File to EXE Not working. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python File to EXE Not working. (/thread-27484.html)



Python File to EXE Not working. - MianDoesCoding - Jun-08-2020

Hey guys so i would i like to make a single python file of mine into an exe
what i do is i save he file in a folder with nothing else and i go to the folder

Then i click on the direction thing and type cmd to open command prompt.

i then type pyinstaller --onefile -w main.py

it comes up with this
Error:
269 INFO: PyInstaller: 3.6 270 INFO: Python: 3.8.3 271 INFO: Platform: Windows-10-10.0.18362-SP0 274 INFO: wrote C:\Users\mians\main.spec 277 INFO: UPX is not available. Traceback (most recent call last): File "c:\users\mians\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\mians\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\mians\AppData\Local\Programs\Python\Python38-32\Scripts\pyinstaller.exe\__main__.py", line 9, in <module> File "c:\users\mians\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\__main__.py", line 114, in run run_build(pyi_config, spec_file, **vars(args)) File "c:\users\mians\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "c:\users\mians\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "c:\users\mians\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build exec(code, spec_namespace) File "C:\Users\mians\main.spec", line 6, in <module> a = Analysis(['main.py'], File "c:\users\mians\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py", line 191, in __init__ raise ValueError("script '%s' not found" % script) ValueError: script 'C:\Users\mians\main.py' not found
but in the cmd promt color.

I am super stuck as it makes the dist, build and main.text files but when i click on them there is nothing in em.

Can someone help? Thanks!


RE: Python File to EXE Not working. - buran - Jun-08-2020

you need to provide full path to main.py or cd current working directory to be the one where the py file is.
cmd will not start in the folder where the py file is by default. As you can see it looks into C:\Users\mians


RE: Python File to EXE Not working. - MianDoesCoding - Jun-08-2020

(Jun-08-2020, 01:08 PM)buran Wrote: you need to provide full path to main.py or cd current working directory to be the one where the py file is.
cmd will not start in the folder where the py file is by default. As you can see it looks into C:\Users\mians

so i would have to list the whole path?
like /documents/tests/wtiter/main.py?


RE: Python File to EXE Not working. - buran - Jun-08-2020

(Jun-08-2020, 01:11 PM)MianDoesCoding Wrote: so i would have to list the whole path?
like /documents/tests/wtiter/main.py
yes, that is one option - use full path (either absolute or relative). the other is to change current working directory to the one where the files is, in which case you don't have to use the full path


RE: Python File to EXE Not working. - MianDoesCoding - Jun-08-2020

(Jun-08-2020, 01:19 PM)buran Wrote:
(Jun-08-2020, 01:11 PM)MianDoesCoding Wrote: so i would have to list the whole path?
like /documents/tests/wtiter/main.py
yes, that is one option - use full path (either absolute or relative). the other is to change current working directory to the one where the files is, in which case you don't have to use the full path

How would i change the directory sir?


RE: Python File to EXE Not working. - buran - Jun-08-2020

cmd will open like this
Output:
C:\Users\mians\>cd C:\Users\mians\Documents\tests\writer
that is assuming the file is in C:\Users\mians\Documents\tests\writer


RE: Python File to EXE Not working. - MianDoesCoding - Jun-08-2020

(Jun-08-2020, 01:26 PM)buran Wrote: cmd will open like this
Output:
C:\Users\mians\>cd C:\Users\mians\Documents\tests\writer
that is assuming the file is in C:\Users\mians\Documents\tests\writer

it is in thispc then Desktop, then Python And then text editor. and in the text editor folder is the main.py
and im stuck on exactly what to write sir


RE: Python File to EXE Not working. - buran - Jun-08-2020

(Jun-08-2020, 01:30 PM)MianDoesCoding Wrote: it is in thispc then Desktop, then Python And then text editor. and in the text editor folder is the main.py
(Jun-08-2020, 01:11 PM)MianDoesCoding Wrote: like /documents/tests/wtiter/main.py?

And I am confused by your explanations... What is the full path of main.py?


RE: Python File to EXE Not working. - NectDz - Jun-08-2020

Go on the folder where the file is saved then you see the path to the file ontop, click on it and erase the path and just type cmd and enter and cmd will open up. Now you should be able to do what you wanted to do on pyinstall


RE: Python File to EXE Not working. - MianDoesCoding - Jun-09-2020

(Jun-08-2020, 02:31 PM)NectDz Wrote: Go on the folder where the file is saved then you see the path to the file ontop, click on it and erase the path and just type cmd and enter and cmd will open up. Now you should be able to do what you wanted to do on pyinstall

thats what i did