Getting started? virtualenv?

2,164 views
Skip to first unread message

Dan Connolly

unread,
Nov 3, 2011, 10:32:22 AM11/3/11
to spyder
I ran across spyder recently, and the combination of features looks
pretty nifty.
http://code.google.com/p/spyderlib/wiki/Features

In particular, code completion.

I have an existing python project, maintained with the usual setup.py
and virtualenv.
http://informatics.kumc.edu/work/browser/raven-j

How can I use Spyder to edit it with code completion?

The project explorer docs say it can "import from existing Pydev
(Eclipse) or Spyder projects."
http://packages.python.org/spyder/projectexplorer.html

But I don't have an existing pydev or spyder project; so what do I do?

What does File/New Project do? Is that only for completely new
projects, or can I use
it to start working with my sources?

How does the PYTHONPATH manager relate to virtualenv?

p.s. I'm on freenode in #swig as DanC. If any other spyder users are
on freenode
and available to hold my hand a bit, please suggest a channel where we
can chat.

--
Dan Connolly, KUMC Medical Informatics http://informatics.kumc.edu/
913-945-6741

anatoly techtonik

unread,
Nov 3, 2011, 6:50:51 PM11/3/11
to spyd...@googlegroups.com
Hi, Dan

From that I can see, Virtualenv is not supported natively by Spyder. But it would be a good addition, indeed. It should not be too hard to add 'execute script in virtualenv' option to 'run' dialog.

anatoly techtonik

unread,
Nov 3, 2011, 7:15:39 PM11/3/11
to spyd...@googlegroups.com
On Thursday, November 3, 2011 5:32:22 PM UTC+3, Dan Connolly wrote:

The project explorer docs say it can "import from existing Pydev
(Eclipse) or Spyder projects."
 http://packages.python.org/spyder/projectexplorer.html

I guess Spyder needs to be extended to import simple directories also. In fact, if you have project in 'project explorer' and then click on any project - there is a menu that allows to Import existing directory. I wonder why there are no such option in File menu? Looks like a bug to me.
 
But I don't have an existing pydev or spyder project; so what do I do? 

As the last resort just open your files and start hacking.
 
What does File/New Project do? Is that only for completely new
projects, or can I use
it to start working with my sources?

That's for the new projects, but it would be convenient if import capabilities were merged into this menu also. Could you add an item for that to tracker?

How does the PYTHONPATH manager relate to virtualenv?

I have no idea how virtualenv sets PYTHONPATH and where does it save the settings. This had to be researched.

Carlos Córdoba

unread,
Nov 5, 2011, 4:52:32 PM11/5/11
to spyd...@googlegroups.com
Hi Dan,

I'm sorry to contradict Anatoly, but Spyder has support for virtualenv.
You can go to:

Tools > Preferences > Console > Advanced Settings > Python Executable

and there you can select the path to the python interpreter of your
virtualenv, e.g something like:

/home/carlos/.virtualenvs/visual/bin/python

if you use virtualenvwrapper as me. After this, you have to click in:

Tools > Update module names list

to update a little database we maintain of the module names in your
PYTHOPATH, so they can be TAB-completed.


A project in Spyder is a tree-like view of your sources dir and saves
some setting as your preferred PYTHONPATH for it. In version 2.1 it can
also let you import and existing dir.

Please let us know if you need any additional help.

Cheers,
Carlos

El 03/11/11 09:32, Dan Connolly escribió:

anatoly techtonik

unread,
Nov 6, 2011, 12:21:56 PM11/6/11
to spyd...@googlegroups.com
2011/11/5 Carlos Córdoba <ccord...@gmail.com>:

>
> I'm sorry to contradict Anatoly, but Spyder has support for virtualenv.

Not really a contradiction. I searched the source and couldn't find any
references. If we support virtualenv's, this should be mentioned
somewhere.

> You can go to:
>
> Tools > Preferences > Console > Advanced Settings > Python Executable
>
> and there you can select the path to the python interpreter of your
> virtualenv, e.g something like:
>
> /home/carlos/.virtualenvs/visual/bin/python
>
> if you use virtualenvwrapper as me. After this, you have to click in:
>
> Tools > Update module names list
>
> to update a little database we maintain of the module names in your
> PYTHOPATH, so they can be TAB-completed.

I see. I thought `virtualenv` should be activated prior to calling
Python, but it seems like interpreter from `virtualenv` directory will
use the appropriate environment automatically. Anyway, the option
seems to be global, not something project-specific.

Dan Connolly

unread,
Nov 7, 2011, 9:30:10 AM11/7/11
to spyd...@googlegroups.com
On Sat, 2011-11-05 at 15:52 -0500, Carlos Córdoba wrote:
> Hi Dan,

>
> I'm sorry to contradict Anatoly, but Spyder has support for virtualenv.

Nice!

> You can go to:
>
> Tools > Preferences > Console > Advanced Settings > Python Executable

I don't see a "Python Executable" under Advanced Settings.

I took a screenshot of what I see:
http://imgur.com/3Yupa


The "About Spyder" dialog says:

Spyder 2.0.6
Scientific PYthon Development EnviRonment
Copyright © 2009-2010 Pierre Raybaut
Licensed under the terms of the MIT License
Created, developed and maintained by Pierre Raybaut
Many thanks to Christopher Brown, Alexandre Radicchi, Ludovic Aubry and
all the Spyder beta-testers and regular users.
Source code editor: Python code real-time analysis is powered by
pyflakes 0.4.0 (© 2005 Divmod, Inc.) and other code introspection
features (completion, go-to-definition, ...) are powered by rope (not
installed) (© 2006-2009 Ali Gholami Rudi)
Most of the icons are coming from the Crystal Project (© 2006-2007
Everaldo Coelho)
Spyder's community:
Bug reports and feature requests: Google Code
Discussions around the project: Google Group
This project is part of Python(x,y) distribution
Python 2.7.1+, Qt 4.7.2, PyQt 4.8.3 on Linux

Carlos Córdoba

unread,
Nov 7, 2011, 9:54:34 AM11/7/11
to spyd...@googlegroups.com
Dan , you need to install the latest stable version, i.e. Spyder 2.1.1,
to have this functionality.

I would like to ask you something else: in your first mail you said:

> I have an existing python project, maintained with the usual setup.py
> and virtualenv

What do you exactly mean by "the usual setup.py and virtualenev"? We
would like to understand better the workflow of our users so we can
improve some code completion features.

Cheers,
Carlos

El 07/11/11 09:30, Dan Connolly escribió:

anatoly techtonik

unread,
Nov 7, 2011, 10:31:39 AM11/7/11
to spyd...@googlegroups.com
2011/11/7 Carlos Córdoba <ccord...@gmail.com>:

> Dan , you need to install the latest stable version, i.e. Spyder 2.1.1, to
> have this functionality.
>
> I would like to ask you something else: in your first mail you said:
>
>> I have an existing python project, maintained with the usual setup.py
>> and virtualenv
>
> What do you exactly mean by "the usual setup.py and virtualenev"? We would
> like to understand better the workflow of our users so we can improve some
> code completion features.

Probably something with setuptools that requires `python setup.py
develop`, like Trac
http://trac.edgewall.org/wiki/TracDev/DevelopmentEnvironmentSetup

I have a good idea to improve development workflow with Spyder, but it
requires some Qt knowledge and 'slightly' more time than I can afford to
prototype it before the New Year. We can discuss it separately if there
is an interest.
--
anatoly t.

Dan Connolly

unread,
Nov 7, 2011, 11:11:55 AM11/7/11
to spyd...@googlegroups.com
On Mon, 2011-11-07 at 18:31 +0300, anatoly techtonik wrote:
> 2011/11/7 Carlos Córdoba <ccord...@gmail.com>:
> > Dan , you need to install the latest stable version, i.e. Spyder 2.1.1, to
> > have this functionality.

I was afraid of that.

2.1.1 doesn't seem to be available as an Ubuntu package yet.
https://launchpad.net/ubuntu/+source/spyder

Here's hoping I find time to build it from source.

I gave it a quick try and failed:

~/src/spyder-2.1.1$ python setup.py develop
Traceback (most recent call last):
File "setup.py", line 16, in <module>
from sphinx import setup_command
ImportError: No module named sphinx

I'm sure the fix for that is straightforward, but one never knows how
long the string of dependencies is...

> > I would like to ask you something else: in your first mail you said:
> >
> >> I have an existing python project, maintained with the usual setup.py
> >> and virtualenv
> >
> > What do you exactly mean by "the usual setup.py and virtualenev"? We would
> > like to understand better the workflow of our users so we can improve some
> > code completion features.
>
> Probably something with setuptools that requires `python setup.py
> develop`, like Trac
> http://trac.edgewall.org/wiki/TracDev/DevelopmentEnvironmentSetup

Yes. In particular, mine is a pyramid project
http://docs.pylonsproject.org/projects/pyramid/1.2/narr/project.html

but perhaps the canonical documentation for "the usual setup.py
and virtualenv" is from pypi:

"Package Authors

To submit a package use "python setup.py upload" (full tutorial)."
-- http://pypi.python.org/pypi

which takes you to http://wiki.python.org/moin/CheeseShopTutorial
and then to http://docs.python.org/distutils/setupscript.html


> I have a good idea to improve development workflow with Spyder, but it
> requires some Qt knowledge and 'slightly' more time than I can afford to
> prototype it before the New Year. We can discuss it separately if there
> is an interest.
> --
> anatoly t.

--

Dan Connolly, KUMC Medical Informatics

913-945-6741

Pierre Raybaut

unread,
Nov 9, 2011, 12:20:05 PM11/9/11
to spyder
Hi,

On 3 nov, 15:32, Dan Connolly <dconno...@kumc.edu> wrote:
> The project explorer docs say it can "import from existing Pydev
> (Eclipse) or Spyder projects."
>  http://packages.python.org/spyder/projectexplorer.html
>
> But I don't have an existing pydev or spyder project; so what do I do?
>
> What does File/New Project do? Is that only for completely new
> projects, or can I use
> it to start working with my sources?

FYI, I've just found out about the following related bug:
http://code.google.com/p/spyderlib/issues/detail?id=826&colspec=ID%20Cat%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&start=100

I've already fixed this in my local repository. I'll push changes
ASAP.

-Pierre
Reply all
Reply to author
Forward
0 new messages