CS50 module prevents ability to import local python files
Filip62 opened this issue · 2 comments
Filip62 commented
### Note: This does not happen on CS50 Web IDE.
### Note: I was using VSCode on my PC.
### Note: It is not necessarily an issue, but I think you should definitely point it out in the course.
While working on pset7 from CS50 on edX,
In the application.py, if I imported the CS50 module before I import the functions in helpers.py,
which is located in the same directory as application.py.
application.py:
import cs50
import re
from flask import Flask, abort, redirect, render_template, request
from html import escape
from werkzeug.exceptions import default_exceptions, HTTPException
from helpers import lines, sentences, substringsThen I get this error:
Traceback (most recent call last):
File "/home/filip/Web/Workspace/similarities/application.py", line 7, in <module>
from helpers import lines, sentences, substrings
ModuleNotFoundError: No module named 'helpers'
But if I move the
import cs50below
from helpers import lines, sentences, substringsor if I move the
from helpers import lines, sentences, substringsabove the
import cs50statement,
Modified application.py:
import re
from flask import Flask, abort, redirect, render_template, request
from html import escape
from werkzeug.exceptions import default_exceptions, HTTPException
from helpers import lines, sentences, substrings
import cs50then everything works fine, because the CS50 module erases the local directory from sys.path from which apllication.py was ran after the local helpers import is done.