jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.52k stars 4.82k forks source link

Trying using kwant via jupyter but it gives me, "ModuleNotFoundError: No module named 'kwant'" #3405

Open coder721 opened 6 years ago

coder721 commented 6 years ago

Pressing shift+enter gives me error as: ModuleNotFoundError Traceback (most recent call last)

in () ----> 1 import kwant ModuleNotFoundError: No module named 'kwant' Have no idea what's the issue? I have installed python 3.7 and kwant (https://kwant-project.org/) and jupyter in windows 10. I am sort of new to Python stuff. Help will be much appreciated.
takluyver commented 6 years ago

It sounds like you're trying an import in two different installations of Python, or two different environments. Check sys.executable to see which Python and environment you're running in, and sys.path to see where it looks to import modules.

Python packages must be installed separately for each copy of Python you use, and if you are using virtualenvs or conda envs, packages must be installed into each environment where you need them. Either the package is not installed in one, or a different version of the package is installed.

To install packages to a particular Python installation or environment using pip, you can run it like this:

path/to/python -m pip install ...
# Replace path/to/python with the path of the Python executable (sys.executable)

If you are using conda environments, you can install packages from conda like this:

source activate myenv  # On Windows, just 'activate myenv' (no 'source')
conda install ...

For more detail, see this blog post.

[ This is a saved reply because I answer similar questions often - sorry if it doesn't exactly fit your case ]

coder721 commented 6 years ago

running sys.executable give: C:\Users\gupta\Anaconda3\python.exe running sys.path gives: ['', 'C:\Users\gupta\Anaconda3\python36.zip', 'C:\Users\gupta\Anaconda3\DLLs', 'C:\Users\gupta\Anaconda3\lib', 'C:\Users\gupta\Anaconda3', 'C:\Users\gupta\Anaconda3\lib\site-packages', 'C:\Users\gupta\Anaconda3\lib\site-packages\win32', 'C:\Users\gupta\Anaconda3\lib\site-packages\win32\lib', 'C:\Users\gupta\Anaconda3\lib\site-packages\Pythonwin', 'C:\Users\gupta\Anaconda3\lib\site-packages\IPython\extensions', 'C:\Users\gupta\.ipython']

I have installed Anaconda. So can I use "source activate myenv # On Windows, just 'activate myenv' (no 'source') conda install ..." in the Anaconda prompt?

takluyver commented 6 years ago

If you open an Anaconda prompt, you can probably follow the instructions from here: https://kwant-project.org/install#conda

akhmerov commented 6 years ago

Kwant dev here: