Having problems with Eclipse Pydev seeing your Flask and Flaskext imports? Why aren’t you just using Emacs? Vim at least… It’s alright though, here is some help to keep Pydev happy (works on Linux, OSX, and Windows).
One good alternative is to download the source and reference that source rather than installed lib source. The lib source exercise does give you a good handle on your current situation as you may have a slight disconnect between versions you installed and versions of external source you cloned. Do what works best for you however.
To make Pydev happy make sure you do the following:
- Create a new Python Interpreter referencing python from your new virtualenv (via preferences, NOT the project preferences).
- Actually reference the newly created interpreter created in step #1.
- Make sure “…/site-packages” is in the list of System PYTHONPATH entries.
- Click ‘force restore internal info” from within the project preferences. (Right click project, properties, “PyDev - PYTHONPATH”, click button “Force restore internal info”.
- Open a file that is flagged with an “import not found”. The act of opening it should start code analysis. Maybe modify some code if you have to. Click save. Sometimes however, you need to kick start the code analysis by editing the line with the import error and then saving.
- Last resort is to either warn or ignore imports. :-).
Preferences -> Pydev -> Editor -> Code Analysis -> Imports [tab] -> “Import not found” [section] -> Change to Warning or Ignore [radio]
At least the IDE won’t be chewing on CPU and you’ll be able to work (ala TextMate). Really though, start using Emacs. If your on Windows PyDev helps - but this is good time to try Linux ;-)
Make sure you do not mix:
- Do not mix your System python and your Virtualenv Python libs. Specifically, do not reference the new Interpreter and then adding external libs (in project prefs) from your virtualenv python. This really isn’t safe because your environment is (obviously) split, unstable, and not reproducible. This is the primary reason for Virtualenv.
- Do not mix your system python libs in with your PYTHONPATH when you create the new virtualenv interpreter. All entries should reference files from the new virtualenv.
- There is one exception, that is the use of shutil and __future__ directives. You may need to add the system python/lib directory as the LAST entry in the python path list.
If Pydev is not able to see Flask Extensions:
- Touch <env>/site-packages/flaskext/__init__.py