I have a 100 lines, 3 years old python scraper that now bug. Starting lines are:
import urllib, re, os, sys, time # line 1: import modules os.chdir(os.pat
Use os.path.abspath():
os.path.abspath()
os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
sys.argv[0] in your case is just a script name, no directory, so os.path.dirname() returns an empty string.
sys.argv[0]
os.path.dirname()
os.path.abspath() turns that into a proper absolute path with directory name.