Skip to content

Instantly share code, notes, and snippets.

@candeira
Created October 26, 2014 05:51
Show Gist options
  • Save candeira/5054323d2dde28a645f6 to your computer and use it in GitHub Desktop.
Save candeira/5054323d2dde28a645f6 to your computer and use it in GitHub Desktop.
Does iPython cache older versions of libraries?
# using ipython 1.2.1 on Ubuntu 14.04
# I have a cloudant-python library installed in a virtualenv
# there was a bug, which I fixed, and ipython-notebook kept
# showing the old behaviour. ipython in the console also shows
# the old behaviour:
$ ipython
WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
Type "copyright", "credits" or "license" for more information.
IPython 1.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: USERNAME, PASSWORD = 'foo', 'bar'
In [2]: DBNAME, DOCNAME = 'thermostat', 'stratus-device-0000000'
In [3]:
In [3]: from cloudant import Account, Database, Document
In [4]: account = Account("http://localhost:5984/")
In [5]: response = account.login(USERNAME, PASSWORD)
In [6]: account.all_dbs().json()
Out[6]:
{u'couchdb': u'Welcome',
u'vendor': {u'name': u'The Apache Software Foundation'},
u'version': u'46cb6a4'}
# the above is not the expected outcome, and this is a bug
# that I had already fixed...
In [7]:
Do you really want to exit ([y]/n)?
# but the python cli does find the current library installed
# and shows the good behaviour
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> account.all_dbs().json()
KeyboardInterrupt
>>> SERNAME, PASSWORD = 'candeira', 'candeira'
>>> DBNAME, DOCNAME = 'thermostat', 'device-0000000'
>>>
>>> from cloudant import Account, Database, Document
>>> account = Account("http://localhost:5984/")
>>> response = account.login(USERNAME, PASSWORD)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'USERNAME' is not defined
>>> USERNAME, PASSWORD = 'foo', 'bar'
>>> DBNAME, DOCNAME = 'thermostat', 'device-0000000'
>>>
>>> from cloudant import Account, Database, Document
>>> account = Account("http://localhost:5984/")
>>> response = account.login(USERNAME, PASSWORD)
>>> account.all_dbs().json()
[u'_replicator', u'_users', u'hello', u'test']
>>>
KeyboardInterrupt
>>>
# and no, the cloudant library is not installed outside
# the virtualenv...
$ deactivate
kandinski@desire:~/data/work/hack/couchdb-fauxton$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cloudant
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cloudant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment