Installing pyqt in a virtualenv to be used with spyder

525 views
Skip to first unread message

max....@gmail.com

unread,
Sep 20, 2013, 8:20:45 AM9/20/13
to spyd...@googlegroups.com
Hello,
I managed to let spyder use the virtualenv that I created (including pip install numpy/scipy/matplotlib/sip).
When I however want to import matplotlib.pyplot I get:

 import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mt/.virtualenvs/def2/lib/python2.7/site-packages/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Users/mt/.virtualenvs/def2/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/Users/mt/.virtualenvs/def2/lib/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py", line 13, in <module>
    from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
  File "/Users/mt/.virtualenvs/def2/lib/python2.7/site-packages/matplotlib/backends/backend_qt4.py", line 25, in <module>
    from qt4_compat import QtCore, QtGui, _getSaveFileName, __version__
  File "/Users/mt/.virtualenvs/def2/lib/python2.7/site-packages/matplotlib/backends/qt4_compat.py", line 36, in <module>
    import sip
ImportError: No module named sip

I suppose, that I also need to install PyQt but pip install PyQt does not find any package (nor does it for python27-pyqt or PyQt4)
I have installed sip (pip install sip), but don't know how I can get any further from here.

I am using Mac OS X 10.8.4 and would really love to continue using spyder, the best IDE for python that I found so far, but the handling of additional packages is driving me insane!

Thanks
max

Carlos Córdoba

unread,
Sep 20, 2013, 8:25:06 AM9/20/13
to spyd...@googlegroups.com
Hi Max,

What is your Spyder version? Are you running it under Anaconda or MacPorts?

El 20/09/13 07:20, max....@gmail.com escribió:
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/groups/opt_out.

max....@gmail.com

unread,
Sep 20, 2013, 11:19:41 AM9/20/13
to spyd...@googlegroups.com
I am using 2.2.1 for Mac, I installed the anaconda distribution that came with the mac *.dmg-file, but my virtualenv seems to be creating an environment from a different python-distribution on my Mac, I installed python27 through homebrew recently, and also have an Enthought python-distribution installed.
I don't know from which one the virtualenv stems.

thanks for the quick reply!

Carlos Córdoba

unread,
Sep 20, 2013, 5:42:42 PM9/20/13
to spyd...@googlegroups.com
Hi Mac,

I guess you are using our DMG, given your version. Then you have to go to:

Spyder > Preferences > Console > Advanced Settings > PYTHONSTARTUP replacement

and select the option

Default PYTHONSTARTUP script

Cheers,
Carlos

El 20/09/13 10:19, max....@gmail.com escribió:

Tim Michelsen

unread,
Sep 22, 2013, 11:38:13 AM9/22/13
to public-spyderlib-/J...@plane.gmane.org


Hello,

> I managed to let spyder use the virtualenv that I created (including pip
> install numpy/scipy/matplotlib/sip).

could you explain how you achieved this?

I am using often a virtualenv.
But how do I activate it in Spyder?
I think this is the next killer feature.

max....@gmail.com

unread,
Sep 22, 2013, 1:35:02 PM9/22/13
to spyd...@googlegroups.com, public-spyderlib-/J...@plane.gmane.org
Hello Carlos,
yes, I also changed this option, however it doesn't help... 
How would you install PyQt through a virtualenv?
Or as an alternative: how can I add a new module to the Anaconda python-distribution?

@Timmie: just set up a virtualenv (with virtualenvwrapper installed just type mkvirtualenv name_of_virtualenv) and then use the console pip install XXX to install whatever you need (PyQt remains a problem and with that also no plotting-functionality)

Tim Michelsen

unread,
Sep 24, 2013, 4:03:54 PM9/24/13
to public-spyderlib-/J...@plane.gmane.org


> then use the console pip install XXX to install whatever you need (PyQt
> remains a problem and with that also no plotting-functionality)
Yes, find.
but how to activate the virtualenv for the IPython within spyder?

That's the missing point for me.

Maximilian Thess

unread,
Sep 24, 2013, 5:28:30 PM9/24/13
to spyd...@googlegroups.com, public-spyderlib-/J...@plane.gmane.org
when you create a virtualenv a folder is created, just use the
python-installation that is located in that folder and set it as the
default compiler/intepreter in spyder-options -> console -> advanced
settings
works for me (except for PyQt)
> --
> You received this message because you are subscribed to a topic in the Google Groups "spyder" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/spyderlib/E15euPkHsKI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to spyderlib+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages