ddeamaral
ddeamaral

Reputation: 1443

Can't reference Lib/site-packages virtualenv flask

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

Answers (1)

ddeamaral
ddeamaral

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

Related Questions