Unable to import jar from project directory, but works everywhere

Thus, I came across a funny problem when trying to use Flask, I can only run it from ~ / (home), and not from ~ / Projects / projectfolder. I am using Python 2.7.4 installed through their homepage, virtualenv and virtualenvwrapper. Each time it’s the same thing:

$ mkvirtualenv project New python executable in project/bin/python Installing setuptools............done. Installing pip...............done. 

Then I check the box:

 $ pip install flask [...] Successfully installed flask Werkzeug Jinja2 Cleaning up... 

Then I open Python from my home directory:

 (project) $ python >>> from flask import Flask >>> 

Then I leave and go to the project folder:

 (project) $ cd ~/Projects/example (project) $ python >>> from flask import Flask Traceback (most recent call last): File "<stdin>", line 1, in <module> File "flask.py", line 1, in <module> from flask import Flask ImportError: cannot import name Flask 

And I lost a little, why is this happening, does anyone have any ideas?

+7
source share
1 answer

In your opinion, you have your own flask.py module in ~/Projects/example .

The current directory is searched before the actual installation path of the package, so it obscures the "real" flask.

+13
source

All Articles