For my program, I have 3 programs They will all be listed bellow
C:\Python\data\fold1\subfile.py
import json
import sys
part = sys.path[0].split('\\') '''This part adds
del (part[part.index('Python') + 1:len(part)]) a system path
sys.path.insert(1, '\\'.join(part)) C:\Python'''
from data.fold2.other import accounts_list
class AddUser():
def __init__(self, username, password, Type=1):
self.username = username
self.password = password
self.Type = Type
accounts_list[self.username] = [self.password, self.Type]
with open('data\\fold2\\other.py', 'w') as file:
file.write('accounts_list = ' + json.dumps(accounts_list))
C:\Python\data\fold2\start.py
import sys
from other import accounts_list
part = sys.path[0].split('\\') '''This part adds
del (part[part.index('Python') + 1:len(part)]) a system path
sys.path.insert(1, '\\'.join(part)) C:\Python'''
from data.fold1 import subfile
subfile.AddUser('username', 'password')
C:\Python\data\fold2\other.py
accounts_list = {}
When I run my main program, start, I get the error:
File "C:\Python\data\fold1\subfile.py", line 16, in __init__
with open('data\\fold2\\other.py', 'w') as file:
FileNotFoundError: [Errno 2] No such file or directory: 'data\\fold2\\other.py'
I have no idea how to resolve this error as I am still a beginner. If anyone knows what to do, please provide an answer.
-Thanks