ModuleNotFoundError: No module named 'ase'

Hi there,

I’m new with Jupyter. I’ve coded this to map molecules and seem to be failing at the first hurdle. I am using anaconda (latest version) and Jupyter Notebook 6.4.5 with a Python 3 (ipykernel). I cannot see any way of changing this. I am running it on a Mac if this makes any difference! I know ase needs a reasonably late Python version but I think I’m running the newest I can.

I’m sure that the code is right, but it will not import the ase module at the start (before the code has even been reached!) It imports other modules fine eg. numpy.

Help! Thank you.

In the notebook where you want to use it, make a cell and paste in the following and run it:

%conda install -c conda-forge ase

After running that in the notebook, if everything goes without a hitch, you can restart the kernel and then make a new cell and try running the import command from ase import Atoms. If that works, you should no longer see ModuleNotFoundError: No module named ‘ase’ when running your code.
You can delete the cell that installed it now, if you prefer. The same for the import test cell.

That install command is based on installing the ASE package in anacona/conda here. You’ll find that page by searching ‘ase anaconda’.

The magic command %conda install will insure the package is installed in the environment underlying the kernel that is backing your notebook.

Amazing! Thank you very much - this looks to have solved my problem.

1 Like

Good to hear. If you get a package that doesn’t have an Anaconda/conda recipe and yet exists on the Python Package Index (PyPI), you can use %pip install to do a similar process to install the package in the associated environment, see here for more about these related magic install commands. However, since Anaconda/conda/mamba is your main package manager it is best to stay with it as much as you can, which will enhance the stability and portability of the associated environments in the long run.