question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't import mne when installing from pip

See original GitHub issue

For various reasons I don’t want to install MNE via the instructions in the documentation, but rather by using pip. However, the package on PyPI is not setup correctly to install dependencies. By simply trying to import mne, I get the following:

>>> import mne
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/depalati/miniconda3/envs/thetamod/lib/python3.6/site-packages/mne/__init__.py", line 25, in <module>
    from .io.pick import (pick_types, pick_channels,
  File "/Users/depalati/miniconda3/envs/thetamod/lib/python3.6/site-packages/mne/io/__init__.py", line 15, in <module>
    from .base import BaseRaw
  File "/Users/depalati/miniconda3/envs/thetamod/lib/python3.6/site-packages/mne/io/base.py", line 22, in <module>
    from ..channels.channels import (ContainsMixin, UpdateChannelsMixin,
  File "/Users/depalati/miniconda3/envs/thetamod/lib/python3.6/site-packages/mne/channels/__init__.py", line 8, in <module>
    from .montage import (read_montage, read_dig_montage, Montage, DigMontage,
  File "/Users/depalati/miniconda3/envs/thetamod/lib/python3.6/site-packages/mne/channels/montage.py", line 19, in <module>
    from ..viz import plot_montage
  File "/Users/depalati/miniconda3/envs/thetamod/lib/python3.6/site-packages/mne/viz/__init__.py", line 6, in <module>
    from .topo import plot_topo_image_epochs, iter_topography
  File "/Users/depalati/miniconda3/envs/thetamod/lib/python3.6/site-packages/mne/viz/topo.py", line 14, in <module>
    from matplotlib.colors import colorConverter
ModuleNotFoundError: No module named 'matplotlib'

This can be fixed by including dependencies with the install_requires keyword argument in setup.py. Alternatively, why is mne/__init__.py importing so many things in the first place? If only a small subset of MNE’s functionality is required, why should a user have to install so many unused dependencies?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
agramfortcommented, May 31, 2018

sklearn 0.20 will do the install_requires for numpy and scipy:

https://github.com/scikit-learn/scikit-learn/blob/master/setup.py#L192

so I guess we could do it 😃

0reactions
mivadecommented, May 31, 2018

Thanks, @larsoner!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install via pip or conda — MNE 1.2.2 documentation
We suggest to install MNE-Python into its own conda environment. ... conda activate mne $ python -c "import sys; print(sys.executable)".
Read more >
python - Unable to import a module that is definitely installed
In my case, it is permission problem. The package was somehow installed with root rw permission only, other user just cannot rw to...
Read more >
MNE installation problem - Support & Discussions
Yes, I tried using pip install, mne-bids is installed in the user folder and could not import to the anaconda environment.
Read more >
PyCharm can't install/import a package/library/module
- run pip install <package_name> or conda install <package_name> accordingly if you have problems installing a package in PyCharm;. Note: be ...
Read more >
Problem with "pip install" - Python Help
I use MacOS. However, I cannot use 'pip' to install library like the following picture. Will someone help me solve my problem?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found