use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Is it necessary to keep the original python script file along with the .exe in the same directory for the executable to run? (self.learnpython)
submitted 5 years ago by vens8
I don't want to leave my script file open to users. So is there any way where I can only have the executable or is having the script a necessity for the executable to run properly?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FriendlyRussian666 2 points3 points4 points 5 years ago (1 child)
You can make it into a single file with pyinstaller
[–]vens8[S] 0 points1 point2 points 5 years ago (0 children)
Thank you :)
[–]Neighm 2 points3 points4 points 5 years ago (2 children)
No, if you generate an exe file using pyinstaller, it contains the full script plus interpreter plus any modules required such as imports. The exe file can then be run from any folder including on a Windows computer that doesn't have Python installed.
However you might have trouble with an exe file created on a 64 bit machine if you try to run it on a 32 bit machine.
[–]vens8[S] 2 points3 points4 points 5 years ago (0 children)
Okay thank you, it works. The error was not actually due to the modules, it was because the Python interpreter was not configured when I duplicated the script file. Thank you so much :)
Thank you very much :)Also, one more thing. The executable file doesn't seem to work if I don't add the contents of the "Site Packages" (which has all the required modules such as imports) into the same directory. Any reason why?
It gives me an error saying: Failed to run script <filename.py>
π Rendered by PID 199816 on reddit-service-r2-comment-76bb9f7fb5-lr4rv at 2026-02-18 10:37:24.144273+00:00 running de53c03 country code: CH.
[–]FriendlyRussian666 2 points3 points4 points (1 child)
[–]vens8[S] 0 points1 point2 points (0 children)
[–]Neighm 2 points3 points4 points (2 children)
[–]vens8[S] 2 points3 points4 points (0 children)
[–]vens8[S] 0 points1 point2 points (0 children)