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:
JavaScript
x
22
22
1
C:UsersWhite PythonDesktopFrantheconfluencegraphsleaderboard>python htmlcreator.py
2
Traceback (most recent call last):
3
File "htmlcreator.py", line 4, in <module>
4
w = open(str(Path(__file__).parents[2]) + "/week.txt", "r")
5
File "C:UsersWhite PythonAppDataLocalProgramsPythonPython38-32libpathlib.py", line 617, in __getitem__
6
raise IndexError(idx)
7
IndexError: 2
8
9
C:UsersWhite PythonDesktopFrantheconfluencegraphsleaderboard>cd ..retention
10
11
C:UsersWhite PythonDesktopFrantheconfluencegraphsretention>python creategraph.py
12
['C:\Users\White Python\Desktop\Fran\theconfluence\graphs\retention', 'C:\Users\White Python\AppData\Local\Programs\Python
13
\Python38-32\python38.zip', 'C:\Users\White Python\AppData\Local\Programs\Python\Python38-32\DLLs', 'C:\Users\White Python
14
AppData\Local\Programs\Python\Python38-32\lib', 'C:\Users\White Python\AppData\Local\Programs\Python\Python38-32', 'C:\Us
15
ers\White Python\AppData\Local\Programs\Python\Python38-32\lib\site-packages']
16
Traceback (most recent call last):
17
File "creategraph.py", line 9, in <module>
18
w = open(str(Path(__file__).parents[2]) + "/week.txt", "r")
19
File "C:UsersWhite PythonAppDataLocalProgramsPythonPython38-32libpathlib.py", line 617, in __getitem__
20
raise IndexError(idx)
21
IndexError: 2
22
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:
JavaScript
1
2
1
python -m htmlcreator
2