Reputation: 1443
I am trying to tinker with Flask and Python using virtualenv. I have made my current working directory C:/Users/dylan/Desktop/TestPython/FlaskTest and activated a virtualenv here. Now when I'm in here and activated, I ran the command pip install flask and the package was copied to Lib/site-packages. I've look at other SO posts, they didn't really explain how to import modules from the site-packages directory.
My folder structure is as follows (directories with M were created manually by me not the activate script)
/TestPython
/Lib (contains /site-packages/flask)
/Include
/resources (M)
/Scripts
/static(M)
/templates (M)
routes.py
Now from my routes.py file, I get an ImportError for trying to import flask. How do I accomplish importing flask in my routes.py file.
Upvotes: 0
Views: 122
Reputation: 1443
So I figured out that Sublime Text does not use the same command line instance that you have open. It doesn't actually build using the virtual environment. I think I need to modify my build system. If I run python routes.py while activated it does work as expected. I was trying to run it from sublime text and that was my mistake. Does anyone know how to modify your build system in sublime text 3 to use virtual environment?
Upvotes: 0