iprofiler icon indicating copy to clipboard operation
iprofiler copied to clipboard

Update installation docs and import methods

Open al626 opened this issue 8 years ago • 2 comments

This isn't so much a pull request as an issue, but seeing as I found a workaround, I thought it would be best to show how I got iprofiler working for me.

Two issues:

  1. I needed to do an npm install to get iprofiler/static/ to appear and allow pip install -e . to work
  2. For some reason, when in IProfilerMagics.iprofile(self, line, cell=None), import iprofiler was importing iprofiler/iprofiler.pyc instead of iprofiler/__init__.pyc, hence the need for the try/except statement.

Thanks for the module!

P.S: Ubuntu 14.04 IPython 5.0.0 Jupyter 4.1.0 Jupyter notebook 4.2.1 npm 1.3.10 nodejs v0.10.25

al626 avatar Jul 25 '16 18:07 al626

Ah thanks a lot for raising this. I've just replicated both of these issues on my own machine. I think a slightly more efficient way to resolve 1 would be to run python setup.py build before pip install -e .. Note that the setup mechanism for my project is currently based on this 'cookie cutter' project template: https://github.com/jupyter/widget-cookiecutter, and therefore this is an issue with the template. I will open an issue on that repo.

As for 2, I believe this problem only occurs in Python 2 (are you running Python 2?), and is to do with absolute vs relative imports (see here). I think I would like to fix it by putting from __future__ import absolute_import at the top of the file.

Fixed 2: https://github.com/j-towns/iprofiler/commit/448eea277034eb82521bd5dcae4d107471ee2757

j-towns avatar Jul 25 '16 23:07 j-towns

Ah, so that's what absolute_import does. Yeah I was using python2.

Having done some more debugging, I believe that the js building should occur in setup.py:101: check_call(['npm', 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)

I've spent some time looking at this and it could be one / a combination of the issues below:

  1. npm does not play well with sudo https://github.com/npm/npm/issues/3497

    I was at one point getting errors such as npm WARN cannot run in wd [email protected] webpack (wd=/home/ubuntu/src/iprofiler/js)

  2. Ubuntu / Debian based systems call node nodejs

    I was also getting issues such as:

      sh: 1: webpack: not found
      npm ERR! weird error 127
      npm WARN This failure might be due to the use of legacy binary "node"
      npm WARN For further explanations, please read
      /usr/share/doc/nodejs/README.Debian
    

    My usual fix of sudo ln -s /usr/bin/nodejs /usr/bin/node didn't work

Hopefully this is somewhat helpful

al626 avatar Jul 26 '16 10:07 al626