Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How import Pydev project into interactive console?

Tags:

python

pydev

Newbie question (I'm just getting started with Python and Pydev):

I've created a project "Playground" with (standard?) src/root sub-folder. In there I've created example.py.

How do I import my "example" module into Pydev's interactive console? ">>> import example" gives: "ImportError: No module named example"

like image 571
David Easley Avatar asked Oct 22 '09 19:10

David Easley


People also ask

How do I get out of PyDev eclipse?

pydev* from eclipse/plugins and eclipse/features or you can go to help > software updates > manage configuration, choose the PyDev plugin and disable it (after that, to completely remove it, you must restart Eclipse and only then select it for uninstall).


2 Answers

You need to set your PYTHONPATH accordingly (Google search is your friend) or use *.pth in your installation site-packages directory pointing to your project path. Don't forget to set your interpreter details with Pydev (Window->Preferences->Pydev->interpreter).

like image 154
jldupont Avatar answered Oct 04 '22 17:10

jldupont


I found the answer on the Plone website: Setting up PYTHONPATH in Eclipse project. This provides a convenient way to set PYTHONPATH on a per project basis. In my case I added "/Playground/src/root" to the Source Folders list. ">>> import example" then worked. (I'm still surprised project files aren't imported by default, though.)

Thank you jldupont for pointing me in the right direction (re. PYTHONPATH)!

like image 41
David Easley Avatar answered Oct 04 '22 16:10

David Easley