Working with Python behind a proxy server

If you’re working behind a proxy server, you may run into some unexpected issues when configuring a work environment with Python and Eclipse. Here are some quick fixes:

Configuring the proxy server in Eclipse:

  1. Window -> Preferences -> General -> Network Settings.
  2. Set the Active Provider drop-down box to Manual.
  3. Edit the HTTP entry in the Proxy Settings list.
  4. Fill in the proxy server and port number (user name and password if necessary).
  5. And here’s MKYong’s long version, with screenshots!

 

Configuring the proxy server for other tasks, like easy_install:

Set an environmental variable:

set http_proxy=http://user:some%20long%20password@webproxy.mycompany.com:80

(The %20‘s are only needed if you happen to have spaces in your password.)

 

Configuring PyDev in Eclipse to work with Django

The pre-requisite for working with Django is that it is installed in the Python interpreter you want to use.

Eclipse will add the Django options to the menu automatically. At this point, you can:

  1.  create a new Django project: Ctrl+N > PyDev Django Project
  2.  change an existing project to Django: right-click the project and choose
    PyDev -> Set as Django Project.
  3. (you can also change projects back in the same way).

In order to compile and run the web server, use the standard CTRL-F11.

  1. Don’t forget to add runserver to the Run Configuration
  2. Add –noreload as well so you can see the console output.

You can find a complete tutorial here.

Eclipse keeps throwing errors

Following a bad shutdown, Eclipse kept constantly throwing weird errors: it couldn’t save or open the workspace, had plugin issues, wouldn’t compile my project, etc.

Restart and reboot didn’t work, and I was at a loss until I tried this:

eclipse -clean

run from the eclipse directory. This cleared the plugins path, resolving the issue!

Make Eclipse launch from a specified workspace

I couldn’t seem to make eclipse launch from the workspace I was using. No matter how I tried setting the defaults, it simply would not load from the last workspace used, and kept reverting to the default workspace (which was empty).

Rather than using Switch Workspace all the time (which is a pain, because it restarts Eclipse each time), it’s quicker just to change the configuration file.

This file is called config.ini and you can find it in the configuration directory of your Eclipse installation:

osgi.instance.area.default=C\:\\Workspace

Change the default value of this row to the path of your workspace.


Alternatively, you can run Eclipse from the command line using the -data tag, which lets you manually choose the desired workspaces.

eclipse -data C:\Workspace

How to Change Eclipse Workspace

How to change an Eclipse Workspace?

Using Eclipse 3.7 (Indigo) over Windows 7, this method works for me:

File -> Switch Workspace -> Other. Type in new workspace name. Once in the new workspace, click File -> Import… and under General choose “Existing Projects into Workspace. Press the Next button and then Browse for the old projects you would like to import. Check “Copy projects into workspace” to make a copy.

The next option *should also* work, but it doesn’t seem to work on my computer. Eclipse voodoo?

Try Preferences -> General -> Startup and Shutdown -> Workspaces. Make sure that the “Prompt for workspace on startup” box is checked. Close  Eclipse and reopen. You should be prompted for the workspace on startup.

Let me know if this works for you, and if so, how!


After transferring the workspace, make sure your compilers are still working and the library paths haven’t changed. I had to reconfigure my Python interpreter, but the C++ CDT compiler seemed to survive the transfer okay.