{"action":"created","issue":{"url":"https://api.github.com/repos/rasbt/watermark/issues/15","repository_url":"https://api.github.com/repos/rasbt/watermark","labels_url":"https://api.github.com/repos/rasbt/watermark/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/rasbt/watermark/issues/15/comments","events_url":"https://api.github.com/repos/rasbt/watermark/issues/15/events","html_url":"https://github.com/rasbt/watermark/issues/15","id":169189042,"number":15,"title":"Wrong package versions within virtualenv","user":{"login":"mrbell","id":2854337,"avatar_url":"https://avatars.githubusercontent.com/u/2854337?v=3","gravatar_id":"","url":"https://api.github.com/users/mrbell","html_url":"https://github.com/mrbell","followers_url":"https://api.github.com/users/mrbell/followers","following_url":"https://api.github.com/users/mrbell/following{/other_user}","gists_url":"https://api.github.com/users/mrbell/gists{/gist_id}","starred_url":"https://api.github.com/users/mrbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrbell/subscriptions","organizations_url":"https://api.github.com/users/mrbell/orgs","repos_url":"https://api.github.com/users/mrbell/repos","events_url":"https://api.github.com/users/mrbell/events{/privacy}","received_events_url":"https://api.github.com/users/mrbell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-03T17:35:17Z","updated_at":"2016-08-03T20:16:00Z","closed_at":null,"body":"I'm not sure how widespread this issue is, or if it's something particular to my setup, but when I use watermark to report package information (using -p) within a jupyter notebook that is running in a virtualenv, version information about system level packages are reported rather than packages installed within my environment. If a package is installed in my virtualenv and not installed at the system level, then I end up getting `DistributionNotFound` exceptions when I try to report the version number using watermark.\r\n\r\nThe problem stems from the call to `pkg_resources.get_distribution`. If I use `get_distribution` directly from within my notebook to report the version of e.g. `numpy` it shows my system level numpy info (v 1.11.0) rather than info about numpy installed within my virtualenv (v 1.11.1). For example:\r\n\r\n> `pkg_resources.get_distribution('numpy')`\r\n> `numpy 1.11.0 (/usr/local/lib/python2.7/site-packages)`\r\n \r\nSimilarly\r\n\r\n> `%watermark -p numpy`\r\n> `numpy 1.11.0`\r\n\r\nBut when I check the version of what is imported:\r\n\r\n> `import numpy as np`\r\n> `np.__version__`\r\n> `'1.11.1'`\r\n\r\nIf I use `pkg_resources` from a python console or script running within a virtualenv, it reports the proper information about packages. But if I use it from an ipython console or jupyter notebook it reports system level information.\r\n\r\nIf this is a widespread issue, should `watermark` find another more robust solution to getting package information other than using `pkg_resources`?"},"comment":{"url":"https://api.github.com/repos/rasbt/watermark/issues/comments/237358458","html_url":"https://github.com/rasbt/watermark/issues/15#issuecomment-237358458","issue_url":"https://api.github.com/repos/rasbt/watermark/issues/15","id":237358458,"user":{"login":"rasbt","id":5618407,"avatar_url":"https://avatars.githubusercontent.com/u/5618407?v=3","gravatar_id":"","url":"https://api.github.com/users/rasbt","html_url":"https://github.com/rasbt","followers_url":"https://api.github.com/users/rasbt/followers","following_url":"https://api.github.com/users/rasbt/following{/other_user}","gists_url":"https://api.github.com/users/rasbt/gists{/gist_id}","starred_url":"https://api.github.com/users/rasbt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rasbt/subscriptions","organizations_url":"https://api.github.com/users/rasbt/orgs","repos_url":"https://api.github.com/users/rasbt/repos","events_url":"https://api.github.com/users/rasbt/events{/privacy}","received_events_url":"https://api.github.com/users/rasbt/received_events","type":"User","site_admin":false},"created_at":"2016-08-03T20:16:00Z","updated_at":"2016-08-03T20:16:00Z","body":"> So installing jupyter within the environment fixes the issue. Maybe that's the right thing to do anyway?\r\n\r\nHm, I usually install ipython/jupyter notebook as well in virtual environments, but maybe that's not a \"normal\" thing to do ;).\r\n\r\nJust to summarize your points to make sure that I understand it correctly:\r\n\r\n- if you run the system jupyter notebook in a virtual environment, watermarks gets version numbers from system python packages\r\n- if you run the virtualenv's jupyter notebook in a virtual environment, it watermarks gets version numbers from virtualenv python packages\r\n\r\nBut you are saying that if you run the system's jupyter notebook in a virtual environment, it will import the virtual environment's packages, not the system python packages, right?\r\n\r\nSo, I guess what we want watermark to report the package version of the package that the jupyter notebook actually imports, no matter whether it's a system or virtual environment notebook. How to do this elegantly I don't know, yet. Hopefully, there's a way to achieve this via `pkg_resources.get_distribution`, I will look a bit around in hope to find a good solution. And please let me know if you have any solution or ideas! :). "}}
{"actor":{"display_login":"rasbt"}}