I’m having trouble using python imports in VS2012. I can’t get the project to compile/run when using imports. If I don’t have any imports, python will run main ok (and print “hello world”). It seems to be an error with VS, maybe a configuration because when I disable exceptions in VS, it runs fine.
At first it errors saying:
[WinError 2] The system cannot find the file specified
If I continue a few times it then shows:
[WinError 2] The system cannot find the file specified: 'C:\\Users\\Drew Cross\\Documents\\Visual Studio 2012\\Projects\\Test\\Model\\__init__.pyd'
Then it finally runs after a couple more continues.
I have the following directory structure:
main.py
Model
/__init__.py
/graph.py
main.py:
import Model.graph
def main():
print('Hello World')
if __name__ == '__main__':main()
graph.py:
class graph():
def __init__(self):
neighbors = []
I’ve seen this when using Python 3.3, which raises new exceptions (such as
FileNotFoundError) that Python Tools for Visual Studio doesn’t yet correctly suppress.A temporary workaround is to ignore the following exceptions, which are commonly raised during the import process. You can do so by adding the following Python Exceptions (via Visual Studio’s Exceptions dialog) and uncheck “User-unhandled” to ignore them.
exceptions.FileNotFoundErrorexceptions.PermissionErrorzipimport.ZipImportErrorMore discussion can be found in this discussion.