Python Forum
Python File to EXE Not working.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python File to EXE Not working.
#1
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!
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(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?
Reply
#4
(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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(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?
Reply
#6
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
(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
Reply
#8
(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?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#9
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
Reply
#10
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question apk file not working on android polya001 0 1,140 Feb-06-2022, 11:58 PM
Last Post: polya001
  Subprocess.Popen() not working when reading file path from csv file herwin 13 14,956 May-07-2021, 03:26 PM
Last Post: herwin
  Logger file rotation not working when python code started from windows service as exe nirvantosh 1 6,629 Jun-14-2019, 03:58 PM
Last Post: nirvantosh
  Working with LibreOffice file FASB 0 1,980 Jun-13-2019, 01:23 PM
Last Post: FASB
  .py File extension now working Pronger05 5 4,323 Sep-26-2017, 08:50 PM
Last Post: nilamo
  how to save python file to working directory rpdohm 3 5,996 Sep-14-2017, 06:16 PM
Last Post: rpdohm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020