twosigma / beakerx

Beaker Extensions for Jupyter Notebook
http://BeakerX.com
Apache License 2.0
2.8k stars 382 forks source link

pip install inside a virtualenv fails #6470

Closed jmsdnns closed 6 years ago

jmsdnns commented 6 years ago

I know conda is the officially supported way to install beakerx. This is consistent with norms inside the data science world. Everyone else in the Python community, however, uses virtualenv's, as it is the official environment system from Python.

Virtualenv supplies its own site.py and does not implement getsitepackages. This causes an issue because beakerx/beakerx/setupbase.py attempts to call it.

$ pip install -e .
Obtaining file:///home/jmsdnns/Projects/twosigma/beakerx/beakerx
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/jmsdnns/Projects/twosigma/beakerx/beakerx/setup.py", line 19, in <module>
        from setupbase import (
      File "/home/jmsdnns/Projects/twosigma/beakerx/beakerx/setupbase.py", line 56, in <module>
        site_packages = site.getsitepackages()[0]
    AttributeError: module 'site' has no attribute 'getsitepackages'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /home/jmsdnns/Projects/twosigma/beakerx/beakerx/

This line is in setupbase.py.

site_packages = site.getsitepackages()[0]

The site_packages variable is never used, so this line serves no purpose, as far as I can tell, and the variable it creates is never referenced.

$ cd ~/Projects/twosigma/beakerx/beakerx
$ grep -R "sitepackages" *
beakerx/setupbase.py:site_packages = site.getsitepackages()[0]
$ grep -R "site_packages" *
beakerx/setupbase.py:site_packages = site.getsitepackages()[0]
$

Removing the line is all that's required for virtualenvs to work.

scottdraves commented 6 years ago

Sounds great but does it still work with conda without defining site_packages?

jmsdnns commented 6 years ago

I just had success doing it.

My specific steps were:

conda create --name beakerx python=3.6
source activate beakerx
cd path/to/this/repo
pip install -e .
beakerx-install
jupyter nbextension enable beakerx --py --sys-prefix
jupyter nbextension enable --py widgetsnbextension

I turned it on and ran code in a Python 3 notebook with success.

jmsdnns commented 6 years ago

I thought I'd grep ~/.conda for getsitepackages to see what'd turn up and it seems conda is also packaging this file with their distributions. Their version implements getsitepackages. That explains why it only came up with virtualenv.