I checked out twisted source code form svn and opened it using eclipse as a Python project. But I also have twisted installed in my system under /usr/lib/python2.6/dist-packages. So the imports in the source code imports the installed version and not the version I checked out from svn.
How can I remove the installed version from the libraries that PyDev searches?
Removing /usr/lib/python2.6/dist-packages from PYTHONPATH is not an option because twisted depends on some of the libraries in that directory ( such as serial library )
When you make a launch in PyDev, it should add the PYTHONPATH of the project(s) before the PYTHONPATH of the interpreter, so, if you create a project with the twisted source code and set the PYTHONPATH (i.e.: source folder) for that project properly, it should find it before the one in the interpreter.
Note that other projects should reference the twisted project you configured in order to access it.
Related
I am developing a C++ app for Linux using Wind River Workbench 4, which uses Eclipse 4.5.2. I have installed Subclipse 1.12.
We maintain our projects in Subversion but previously haven't used Subclipse. Our workflow has been:
Create a new Workbench (CDT) project "in an external location" in
my svn workspace in C:\SVNProj\ (I'm working on Windows).
Save it
Import the project into my Eclipse workspace
(C:\WindRiver\workspace)
Add source files to the project as links to the files under C:\SVNProj\.
This worked fine, although remembering to use links was a bit of a pain.
Now I am wondering if the workflow would be easier using Subclipse. I guess that links are then no longer necessary, but I don't understand how that workflow works.
Do I end up with an svn workspace within the Eclipse workspace?
How would I import the existing project that I can see under C:\SVNProj\?
Do I just import the project directory or all of 'trunk'?
best regards
David
Try importing your project, but without copying into your workspace. Doing that will mean you edit in your SVN directory directly, presumably as you expect.
Our company used to use Eclipse for all kinds of python development. We can create PyDev, GAE, or Django projects, but how do we create a Mezzanine project in Eclipse? There seems very little document about it.
Miles Clark has answered this question over here. The releveant part is:
Working with eclipse/pydev (not aptana, but it should be very similar), I normally create the project outside of eclipse and import it. Roughly the steps are:
Create a virtualenv (I use virtualenvwrapper for this). I include system site packages because I've found it easiest to install python-imaging and psycopg2 through the Ubuntu package manager rather than in each virtualenv. I then install Mezzanine into the virtualenv, and create the project using the command line as described in the docs.
Once that's done, I'll create an interpreter entry in PyDev for the new virtualenv (Window > Preferences > PyDev > Interpreter - Python) and then import the project into eclipse. Normally, I'll setup the new project in git and then import the git repo, but you can import without that if you'd like. Choose pydev project, and make sure & choose the new interpreter that you created.
There's normally a little setup once the project's created in PyDev. Make sure the project is marked as a Django project, and then see "Project Source Folders" in Properties > PyDev - PYTHONPATH and the two settings in Properties > PyDev - Django.
I have used Eclipse Indigo (C/C++) for sometime along with PyDev Plugin (for Python). As I messed up with the IDE (tried to tweak some core files, for fun!), I thought to install a fresh one and this time I downloaded Eclipse Indigo (for Java).
Eclipse (C/C++) was placed in C:/
Eclipse (Java) was even placed in C:/
Now when I opened Eclipse (Java), I observed two things:
The Eclipse's title bar still showing <C/C++ Eclipse>
There was a python's project file still opened up which I worked on Eclipse C/C++ IDE. Also, there was an PyDev's error popped up (mentioning it wasn't installed).
I have verified "Installed Plugins" list and didn't find any plugin related to C/C++ or python.
Now, I have got one question:
As I searched over google and found that Eclipse doesn't store anything beyond its directory, How does this above things are showing up??
There might be some Temp/ Cache files stored. However, I searched my drive with "Eclipse" and "PyDev" as keywords and found nothing.
I even searched for registry keys but couldn't find anything.
What exactly is happening and how do remove Eclipse completely?
TL;DR: using the new Eclipse (Java), select "File > Switch Workspace... > Other...", and create a new directory (e.g. java-wks) for all projects you will do using the new Eclipse.
The long explanantion is that Eclipse stores data in two locations:
The eclipse installation directory itself: contains the plug-ins you install (including the ones already installed in the package you downloaded) and some runtime configuration parameters (see eclipse/config.ini) related to how Eclipse itself should run (e.g. where to find the JRE to execute Eclipse itself, how much memory to allocate etc.)
The workspace(s), where your data (projects and source code) and all personal configuration parameters are stored. This is where Eclipse remembers where your source code is, which file(s) where opened when you last exited, which perspective was active (in your case C/C++ Eclipse), your preferences, launch configurations, breakpoints, etc.
For each Eclipse installation on your system (eclipse folder), you can have as many workspaces as you want (it helps to isolate work). There are various ways to select the workspace location: using the -data <path-to-workspace> option on the command-line, using the popup Eclipse normally shows when starting up (but you may have disabled it), or using "File > Switch Workspace...".
You can also use the same workspace from different Eclipse installations (though not at the same time), but things will not work well if you have different plug-ins installed in each: if one installation stores in the workspace "this is a Python project, and the current perspective is C/++", and the other installation does not have the Python and/or C++ plug-ins installed, it will not known what to do with these info. This is why you see the errors you reported.
For your case, my guess is that under Windows the default workspace location is somewhere in your home directory, and the new (Java) Eclipse is using that, but failing to make sense of the Python and C++ related preferences and projects the previous Eclipse stored there. You need to use a fresh workspace not "polluted" with Python and C++ stuff if you want the Java Eclipse to work without errors (or install the Python and C++ plug-ins in the new Eclipse). You may want to enable the Prompt for workspace on startup preference (in "General > Startup and Shutdown > Workspaces") if it is not to control this easily each time Eclipse starts.
hm..
Sometime, PyDev say "Unresolved import error".
In my environment
Python2.6.6 Eclipse3.7 PyDev2.2.2
Errors are.
> Unresolved import: pycassa -> import pycassa Unresolved import:
> WebSocketHandler -> from geventwebsocket.handler import
> WebSocketHandler Unresolved import: tweepy -> import tweepy
Is there any helpfull information?
Had the same problem. In the end I was able to fix the problem by deleting my old interpreter in Preferences > PyDev > Interpreters, and creating a new interpreter called "python" which had the correct paths. After quitting and reopening eclipse, pydev found all my modules.
Probably your PYTHONPATH is not set properly (or if those are libraries in the interpreter, maybe you added them after configuring it).
See: http://pydev.org/manual_101_interpreter.html for references (note the part on forced builtins there as it might be your case).
You get an unresolved import if the required module cannot be found. Modules are searched for in the current working directory and the directories listed in sys.path. Your python cannot find the modules pycassa and tweepy it appears.
Might want to check this: http://klaith.wordpress.com/2009/06/12/pydev-unresolved-import-errors/
I solved by recreate the interpreter. There is a guide at pedev.org:
What if I add something new in my System PYTHONPATH after configuring
it?
If you add something to your python installation, you need to either
add it manually as a 'new folder' in the System PYTHONPATH (if it's
still not under a folder in the PYTHONPATH) or (recommended) remove
your interpreter and add it again, then, press apply.
Note that if you added a library that's already under a folder in the
PYTHONPATH, you have to at least go to the interpreter preferences and
press apply so that it clears its internal caches (after the
configuration is done, things are set in stone for PyDev)
Thanks for Fabio Zadrozny and nicodjimenez.
I had a similar problem before. I solved the problem by this steps:
1)Window > Preferences > PyDev > Interpreters > Python Interpreter
2)Delete the Python Interpreter path you added previously
3)Add "New" Python Interpreter and choose python.exe path
4)Check Libraries tab (I found the problem at this step.)
Check your path name, is it true or false? Eclipse detect "C:\Python27\lib" but it should be "C:\Python27\libs" and "C:\Python27\Lib".
In the properties for your pydev project, there's a pane called "PyDev - PYTHONPATH", with a sub-pane called "External Libraries". You can add source folders (any folder that has an init.py) to the path using that pane. Your project code will then be able to import modules from those source folders.
Check this two links it may be helps to you,
Unresolved Import Issues with PyDev and Eclipse
Unresolved import: models
Is pycassa found as a symlink within a directory on your PYTHONPATH? Pydev apparently has a bug where its code analysis cannot follow symlinks (and hence will not see your libraries). The python interpreter can though of course.
I was having a similar problem with the dbfpy module.
I had downloaded the tar archive and installed the source files in /usr/lib/python2.7/dist-packages
With this I was able to import the packages in IDLE and even run the code in Eclipse. However the pydev import was still showing as an error with the message "unresolved import"
As suggested by Fabio, I checked the PyDev documentation for forced-builtins. Just adding the name of the package ("dbfpy" in my case to the Forced Builtit tab of Python Interpretr in Eclipse) solved the issue.
(I know the answer is a bit late)
if you installed a python package using, for example: pip install django
i solved the unresolved import issue doing this:
In eclipse:
Window > Preferences
In the left panel tree structure go to:
PyDev > Interpreter - Python
In the upper right panel be sure to have the correct interpreted selected
and in the bottom right panel, click New Folder, navigate to your python installation site-packages (usually in c:\Python33\Lib\site-packages) and search for a folder that ends with .egg-info
In my pc it is "C:\Apps\Environments\Python33\Lib\site-packages\Django-1.5.4-py3.3.egg-info" since i installed python in C:\Apps\Environments, should be different in your case.
This worked with django and selenium, should work with all others as well (as far as i know)
Adding the corresponding package folder ending with '.egg-info' to PyDev > Interpreter - Python - library will resolve the problem.
In Linux, it is usually under /usr/local/lib/pythonX.X/dist-packages
Add site-packages path in environmental variables.
Right click on
computer -> properties -> advanced system settings -> Environmental
variables
.
After that is done, remove the python interpreter and add it again in eclipse.
right click project name in
eclipse --> properties --> python interpreter
.
Hope it works.
I am a first time user of Python, I have Eclipse (Helios) on Windows XP and Pydev installed and all is well except that when I am following the GAE tutorial for Python
I get the unresolved import error on run_wsgi_app and webapp from
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
The code runs fine.
I have looked for an answer and added
F:\Program Files\Google\google_appengine\google\appengine\ext and
F:\Program Files\Google\google_appengine\google\appengine\ext\webapp
to be sure to my PYTHONPATH via the Eclipse Python Interpreter interface.
I have removed and re-added the interpreter, pressed Apply, restarted Eclipse but all to no avail.
I am posting this as I am sure many new users with GAE + Python + Eclipse + Pydev would have the same problem.
Regards,
Chris
Add the package parent directory (the first directory with a init.py file)
F:\Program Files\Google\google_appengine
to the PYTHONPATH in Eclipse under the 'External Libraries' tab.
Also beware of a bug in PyDev that does not respect/understand Python namespaces (as opposed to packages). For more info see:
http://sourceforge.net/tracker/index.php?func=detail&aid=3284882&group_id=85796&atid=577329
In general, add the package's parent directory to PYTHONPATH, not the module subdirectories:
F:\Program Files\Google\google_appengine
adding ${GOOGLE_APP_ENGINE}/lib/webapp2-2.5.2 to the "External Libraries" worked for me.
App Engine SDK ver:1.8.2
Python version: 2.7