Reputation: 535
I have a python program that's called by a bash script. The output of the bash script is saved into a log file.
At first the python code threw an error due to a missing config file(wrong location).
This is how the log file looked like,
python /tda/elasticsearch/init_upload.py --lang_pair=en-us_ru-ru 350 372 408 580 615 635 664 67
2 678 690 714 743 765 818 833 855 878 900 924 948 1016 1041 1056 1086 1142 1161 1233 1339 1343
1353 1355 1412 1468 1477 1480 1503 1504 1505 1514 1520 1533 2212 2243 2268 2301 2387 2430 2441
2448 2453 2462 2568 2608 2617 2618 2671 2686 2698 2712 2741 2752 2762 2782 2786 2794 2805 2825
2837 3106 3279 3323 3331 3339 3348 3564 3566 3591 3618 3632 3644 3650 3685 3687 3704 3709 3710
3711 3712 3713 3733 3735 3742 3756 3802 3902 3937 3965 4145 4185 4258 4299 4300 4566 4604 4605
4776 4851 4877 5000 5242 5244 5245 5247 5294 5300 5302 5327 7301 7518 7544 7639 7640 7641 7656
Traceback (most recent call last):
File "/tda/elasticsearch/init_upload.py", line 9, in <module>
from init import query_all
File "/tda/elasticsearch/init.py", line 8, in <module>
from langpair import LanguagePair
File "/tda/elasticsearch/langpair.py", line 2, in <module>
from index import Index
File "/tda/elasticsearch/index.py", line 14, in <module>
CONF_DIR = "%s/confs" % CONFIG.workingdir
AttributeError: 'Config' object has no attribute 'workingdir'
I later fixed the error and reran the program, but somehow the source code changes doesn't seem to be reflecting when I execute the program. I keep getting the same error even after deleting the log file and running the program again.
Python complains about this line,
File "/tda/elasticsearch/index.py", line 14, in <module>
CONF_DIR = "%s/confs" % CONFIG.workingdir
But this line has been updated to,
CONF_DIR = os.path.join(CONFIG.workingdir, "confs")
So somehow the source code change is not reflected.
Upvotes: 2
Views: 4625
Reputation: 148880
It should not happen, because normally Python is clever enough to find when a file has been edited, but sometimes a stale .pyc file is used - it normally is a hint that weird things have occured.
The fix is simply to remove all .pyc files in the folder, they will be re-created (from current source) on next run.
pyc file is just compiled (bytecode) python that is cached to speed up execution.
Upvotes: 1