Git Product home page Git Product logo

Comments (3)

jhu960213 avatar jhu960213 commented on June 14, 2024

@diego-plan9 Do you know what's going on?

from aihwkit.

diego-plan9 avatar diego-plan9 commented on June 14, 2024

It seems to boil down to making jupyter aware of where the package lives - there are a couple of scenarios:

  1. if using a "developer install", the process concludes with python setup.py build_ext --inplace and the package is not installed from pip's perspective. We recommend this approach when intending to make changes to the source code, as it avoids having to reinstall every time a change in the source code is made - the drawback is that it involves manual handling of PYTHONPATH.
  2. if using an "advanced install", the process concludes with the package being installed from pip's perspective. This makes it discoverable by pip and the rest of the tools (including jupyter) in the same way as any other package, but makes it more tedious to try new changes in the source code.

I'm inferring your case is more similar to 1 - if that is the case, it might be just a matter of how jupyter is invoked. Assuming (and from your replies on #65 seems like a safe assumption!) you managed to compile and are able to execute the examples, can you try from the root folder of the cloned repo (and inside an activated virtualenv/conda env):

$ PYTHONPATH=/src jupyter notebook

That would be akin to "starting jupyter, instructing the Python interpreter used to invoke jupyter to look into src/ when importing modules". If that is successful (and if you find that pre-pending that string to all your usual commands gets cumbersome), you can make the modification to PYTHONPATH a bit more permanent by doing:

$ export PYTHONPATH=/path/to/your/cloned_repo/src/

This would set the environment variable for all the commands you issue in that terminal.

If that does not work or you are unable to control how jupyter is launched, there are some workarounds tackling the issue from a different angle - ie. inside Juypter. Within your notebook, you can add a cell at the top with a content similar to:

import sys
sys.path.append("/path/to/your/cloned_repo/src/")

Which can be made more generic by tweaking your jupyter config. However, this workaround tends not to be too portable and I'd recommend trying to solve it via correctly setting the python path - let's see if the first approach yields good results in your environment!

from aihwkit.

diego-plan9 avatar diego-plan9 commented on June 14, 2024

Closing as the issue has been inactive for a while: please reopen if needed.

from aihwkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.