user1867563
user1867563

Reputation: 351

Python packages installed with pip in a virtual environment do not work in eclipse

I am new to pyDev and Eclipse. I am going crazy trying to figure out how to run new installed packages from within Eclipse (so I can see results in the console). I did set up the interpreter within Eclipse to point to the virtual environment using instructions found here: http://www.caktusgroup.com/blog/2011/08/31/getting-started-using-python-eclipse/

Here is what I did. Created a virtual environment and installed a new package (pandas) using pip. I then test some code

from pandas.io.data import DataReader

If I test this line by invoking the python interpreter in the virtual environment, it all works well. However, if I run the line within eclipse I get errors.

All to no avail. Here are the errors I get:

'module' object has no attribute 'tslib'
Traceback (most recent call last):
  File "/Users/tomasisakowitz/Dropbox/workspace/Portfolio/Portfolio/transactions.py", line 474, in <module>
    from pandas.io.data import DataReader
  File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 31, in init pandas.tslib (pandas/tslib.c:48782)
  File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/dateutil/parser.py", line 22, in <module>
    from io import StringIO
  File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/io/__init__.py", line 1, in <module>
    import sql
  File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/io/sql.py", line 10, in <module>
    from pandas.core.datetools import format as date_format
  File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/core/datetools.py", line 3, in <module>
    from pandas.tseries.tools import *
  File "/Users/tomasisakowitz/python_environments/django_tomas/lib/python2.7/site-packages/pandas/tseries/tools.py", line 8, in <module>
    import pandas.tslib as tslib
AttributeError: 'module' object has no attribute 'tslib'

Upvotes: 1

Views: 601

Answers (1)

Guy Gavriely
Guy Gavriely

Reputation: 11396

to add virtualenv to Eclipse PyDev workspace go to Window menu entry and choose preferences, in the open dialog go to PyDev->Iterpreter-Python.

In the Library tab click the "New Folder" button and add your vitrual env. directory.

mine looks like

/home/guy/.virtualenvs/my-env/lib/python2.7/site-packages/

Upvotes: 1

Related Questions