I have two python files: Project_1.py
is the main file. config.py
is the configuration file which contains the location paths. When I run project_1
locally it works perfect. It constantly moves files from location A to Location B exactly as I wanted.
So my goal was to create a python executable of the above program, so I did this: pyinstaller --onefile -w project_1.py
in cmd.
So I copied project_1.exe,
config_py
and the data in LocationA
and LocationB
to a new environment (OS windows, but without Python):
So I adjusted the paths in config.py
with notepad++ to the new paths in the new environment and tried to run project_1.exe
by double clicking on it. This is what I got:
This is the source code of project_1.py
locally:
import os
import shutil
import config as cfg
def move_files(source, destination):
files = os.listdir(source)
for f in files:
f_path = os.path.join(source, f)
shutil.move(f_path, destination)
if len(os.listdir(cfg.location_a)) == 0:
move_files(cfg.location_b, cfg.location_a)
elif len(os.listdir(cfg.location_b)) == 0:
move_files(cfg.location_a, cfg.location_b)
This is the source code of config.py
locally:
location_a = r'C:\Users\FFF\Desktop\Learn Airflow\pythonproject\LocationA'
location_b = r'C:\Users\FFF\Desktop\Learn Airflow\pythonproject\LocationB'
I don't have a clue what is going on, it seems like the config.py
does not seem to be recognized but I don't know.