Problem running PyDev-developed apps in terminal
Im having some import problems with an application I developed in python with Eclipse/PyDev. Running the app from within 开发者_如何学JAVAEclipse is no problem but when I try running it through the linux terminal the imports (which are imported from other folders (packages in Eclipse)) are broken and I get an ImportError: No module named xxx..
From previous experiences developing Java-apps in Eclipse I always solved this through exporting the project to a runnable jar-file but this isn't an option with Python.
Is there a way of circumventing this? I'd rather not put all my .py-files in a single folder since I very much like the package-system (guess Java has damaged me). Can I change the import statement to make it work in both Eclipse and the terminal or do I have to abandon PyDev if I want this to work in the terminal?
Thanks for any help!
Slim
The key here is that PyDev and Eclipse manage a custom Python Path when you're launching within Eclipse. You can modify your environment variables to contain a more complete PYTHONPATH value that contains the locations where you're importing from, or you can use sys.path.append()
to add directories to the path at run time so that the imports can be resolved.
精彩评论