I’m working on some python scripts using PyCharm. Running scripts from PyCharm works fine, but I tried bundling them up with a batch file and cmd just goes nuts:
C:UsersWhite PythonDesktopFrantheconfluencegraphsleaderboard>python htmlcreator.py
Traceback (most recent call last):
File "htmlcreator.py", line 4, in <module>
w = open(str(Path(__file__).parents[2]) + "/week.txt", "r")
File "C:UsersWhite PythonAppDataLocalProgramsPythonPython38-32libpathlib.py", line 617, in __getitem__
raise IndexError(idx)
IndexError: 2
C:UsersWhite PythonDesktopFrantheconfluencegraphsleaderboard>cd ..retention
C:UsersWhite PythonDesktopFrantheconfluencegraphsretention>python creategraph.py
['C:\Users\White Python\Desktop\Fran\theconfluence\graphs\retention', 'C:\Users\White Python\AppData\Local\Programs\Python
\Python38-32\python38.zip', 'C:\Users\White Python\AppData\Local\Programs\Python\Python38-32\DLLs', 'C:\Users\White Python
AppData\Local\Programs\Python\Python38-32\lib', 'C:\Users\White Python\AppData\Local\Programs\Python\Python38-32', 'C:\Us
ers\White Python\AppData\Local\Programs\Python\Python38-32\lib\site-packages']
Traceback (most recent call last):
File "creategraph.py", line 9, in <module>
w = open(str(Path(__file__).parents[2]) + "/week.txt", "r")
File "C:UsersWhite PythonAppDataLocalProgramsPythonPython38-32libpathlib.py", line 617, in __getitem__
raise IndexError(idx)
IndexError: 2
Other scripts which did not require importing modules worked fine. Help!
Advertisement
Answer
Is your html creator a script? Or more like module? If it’s like a module the try:
python -m htmlcreator