웹 응용 프로그램과 내 서버에 연결된 모바일 응용 프로그램이 있습니다. 내 서버에는 로컬 XML 파일에서 데이터를 읽는 다른 모듈 (config.py)을 사용하는 모듈 (md.py)이 있습니다.IOError : [Errno 2] 가끔 그런 파일이나 디렉토리가 없습니다.
config.py (간접적으로)에서 내 애플 리케이션의 데이터 요청을 보낼 때 모든게 잘 작동합니다. 이 문제는 같은 컴퓨터에있는 md.py의 config.py를 호출 할 때 발생합니다.
이
계층 구조입니다 :root/
start.py
md/
__init__.py
md.py
server/
__init__.py
config.py
server.py
data/
config.xml
이이 config.py
import xml.etree.ElementTree as ET
CONF_FILE = "data/config.xml"
class Config:
def __init__(self):
self.file = ET.parse(CONF_FILE)
self.root = self.file.getroot()
입니다 md.py
from server import config
class Md:
def get_data(self):
conf = config.Config() # Errno 2 here
입니다 그리고 내가 start.py
def start():
global server_p
server_p = subprocess.Popen('python ./server/server.py')
md = subprocess.Popen('python ./md/md.py')
이 문제를 해결하려면 어떻게해야합니까?
config.py 파일을 ls 명령으로 실행 해보십시오. 실제로 작업 디렉토리가 실제로 위치한 디렉토리와 같지 않을 수도 있습니다. – Natecat
동적으로 올바른 경로를 얻을 수있는 방법이 있습니까? –