I'm trying to import the file File.py file from a specific directory, C:\MyPythonFiles. This is what I tried(among several other different attempts):
import sys
sys.path.append("c:\MyPythonFiles")
import File.py
Can someone please tell me how to import File.py from the diretory C:\MyPythonFiles ?
Removing the .py so that its 'import File' didn't work either:
[UPDATE]
So in my File.py, I had an import for a file that I did not include in c:\MyPythonFiles, so that was a huge problem.
I edited File.py so it only has one function, printHello(). The script works, but PyCharm still does not recognize 'File' for import. I can still use the line File.printHello(), but it's annoying since PyCharm is not autofilling the functions for 'import File'. Any ideas on how to solve this new problem?
[UPDATE] I think @alex answered the original question, and my PyCharm issue should be a seperate question. Thanks for the help @alex!