이것은 나를 벽으로 몰고 왔습니다. 나는 다음과 같은 트리 구조의 장고 프로젝트를 가지고 있고,Django ModuleNotFound 스크립트의 경우
load_professors_into_db.py
는 다음과 같은 코드가 루트 디렉토리에서 python helper_scripts/load_professors_into_db.py
를 실행하려고 :
## TODO: FIX THIS DAMN IMPORT PATH. THE SCRIPT DOESNT RUN CAUSE OF IT
from ocubulum_dashboard.models import Researcher
import pandas as pd
df = pd.read_csv("helper_scripts/soc_myaces_list.csv")
df = df.dropna()
df = df[~pd.isnull(df["scopus_id"])]
df = df[df["scopus_id"] != 'None']
그러나, 그것은 ModuleNotFound 오류를 시도하고 유지합니다. 난 __init__.py
파일을 사방에 시도했지만, 그 중 하나를 작동하지 않습니다.
Traceback (most recent call last):
File "helper_scripts/load_professors_into_db.py", line 10, in <module>
from ocubulum_dashboard.models import Researcher
ModuleNotFoundError: No module named 'ocubulum_dashboard'
이 문제는 발생하지 않습니다. scopus_scraper.py
과 같이 실행하고 싶은 다른 스크립트의 경우이 어리석은 임포트 문제도 직면합니다.
Traceback (most recent call last):
File "data_collectors/scopus/scopus_scraper.py", line 1, in <module>
from ocubulum_dashboard.models import Researcher
ModuleNotFoundError: No module named 'ocubulum_dashboard'
누군가가이 문제를 해결하는 방법을 가르쳐 줄 수 있습니까? 나는 파이썬 3.6에있다.
전체 폴더 구조는 :
├── data_aggregators
│ ├── myaces_aggregator.py
│ └── scopus_aggregator.py
├── data_collectors
│ ├── execute_all.py
│ ├── __init__.py
│ ├── journals
│ │ ├── __init__.py
│ │ ├── journal_scraper.py
│ │ ├── master.py
│ │ ├── __pycache__
│ │ │ └── __init__.cpython-36.pyc
│ │ └── test.json
│ ├── nus_myaces
│ │ ├── __init__.py
│ │ ├── master.py
│ │ └── __pycache__
│ │ └── __init__.cpython-36.pyc
│ ├── __pycache__
│ │ └── __init__.cpython-36.pyc
│ └── scopus
│ ├── __init__.py
│ ├── master.py
│ ├── __pycache__
│ │ └── __init__.cpython-36.pyc
│ ├── scopus_scraper.py
│ └── scopus_wrapper
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ └── scopus_wrapper.cpython-36.pyc
│ └── scopus_wrapper.py
├── environment.yml
├── helper_scripts
│ ├── __init__.py
│ ├── load_professors_into_db.py
│ ├── __pycache__
│ │ └── __init__.cpython-36.pyc
│ └── soc_myaces_list.csv
├── __init__.py
├── manage.py
├── ocubulum
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ ├── settings.cpython-36.pyc
│ │ ├── settings_development.cpython-36.pyc
│ │ ├── urls.cpython-36.pyc
│ │ ├── views.cpython-36.pyc
│ │ └── wsgi.cpython-36.pyc
│ ├── settings_development.py
│ ├── settings.py
│ ├── static
│ ├── urls.py
│ ├── views.py
│ └── wsgi.py
├── ocubulum_dashboard
│ ├── admin.py
│ ├── apps.py
│ ├── __init__.py
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ ├── __init__.py
│ │ └── __pycache__
│ │ ├── 0001_initial.cpython-36.pyc
│ │ └── __init__.cpython-36.pyc
│ ├── models.py
│ ├── __pycache__
│ │ ├── admin.cpython-36.pyc
│ │ ├── apps.cpython-36.pyc
│ │ ├── __init__.cpython-36.pyc
│ │ ├── models.cpython-36.pyc
│ │ ├── tests.cpython-36.pyc
│ │ └── views.cpython-36.pyc
│ ├── static
│ │ ├── css
│ │ │ ├── custom.css
│ │ │ └── side-menu.css
│ │ ├── img
│ │ │ └── logo.png
│ │ └── js
│ │ └── ui.js
│ ├── templates
│ │ └── ocubulum
│ │ ├── dashboard.html
│ │ └── layout.html
│ ├── tests.py
│ └── views.py
├── Procfile
├── __pycache__
│ └── __init__.cpython-36.pyc
├── README.md
├── requirements.txt
└── runtime.txt
어느 쪽도 작동하지 않는 것 같습니다. – Wboy