This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
3
Script doesn't work after I converted it to .EXE
Post Body
I have a program that:
- Imports modules OS and shutil
- Gets the desktop directory and creates a folder called 'Zenith' in it
- Gets the python script's directory
- Searches for FilesToCopy.txt in the python directory and copies it's text as a list (FilesToCopy.txt contains a list of files that need to be copied)
- Searches the directory for the files written in FilesToCopy.txt and copies them to the Zenith folder on the desktop
When I run the code trough pycharm it works perfectly, but when I compile it to .exe file using pyinstaller it just creates the Zenith folder and does nothing else. It even closes automatically, even though I put input() at the end. What do I do to fix it?
Here is the code:
import shutil
import os
FileName = []
#Get the desktop directory and create a folder called Zenith on it
DesktopDirectory = os.path.join(os.path.join(os.path.expanduser('~')), 'Desktop')
if not os.path.isdir(DesktopDirectory "\Zenith"):
os.mkdir(DesktopDirectory "\Zenith")
TargetFolderDirectory = DesktopDirectory "\Zenith"
#Get the python's executable path
real_path = os.path.realpath(__file__)
dir_path = os.path.dirname(real_path)
#Get text file as string and convert it to a list
with open(dir_path '\FilesToCopy.txt') as f:
lines = f.read()
lines = lines.split(', ')
FileName = lines
print(lines)
f.close()
#Do the copying
for i in FileName:
source = dir_path '\FilesToCopy\\' i
shutil.copy(source, TargetFolderDirectory)
input()
Author
Account Strength
100%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
42,634
Link Karma
11,138
Comment Karma
31,257
Profile updated: 1 day ago
Posts updated: 1 year ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...