# Error importing mne on Windows

**URL:** <https://mne.discourse.group/t/error-importing-mne-on-windows/6254>\
**Category:** Support & Discussions\
**Created:** [January 27, 2023, 10:56am UTC](https://mne.discourse.group/t/error-importing-mne-on-windows/6254 "2023-01-27T10:56:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![timonmerk](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/timonmerk/32/276_2.png) [@timonmerk](https://mne.discourse.group/u/timonmerk)\
**Post date:** [January 27, 2023, 10:56am UTC](https://mne.discourse.group/t/error-importing-mne-on-windows/6254/1 "2023-01-27T10:56:07Z")

</div>

I am to import mne-python using the github actions automatic testing, and get the following error when importing

- MNE version: 1.3.0
- operating system: Windows 10

using Windows only.

`import mne`

> .tox\py310\lib\site-packages\mne\__init_\_.py:130: in   
> set\_log\_level(None, False)  
> .tox\py310\lib\site-packages\mne\utils\_logging.py:204: in set\_log\_level  
> verbose = get\_config(‘MNE\_LOGGING\_LEVEL’, ‘INFO’)  
> .tox\py310\lib\site-packages\mne\utils\config.py:234: in get\_config  
> config\_path = get\_config\_path(home\_dir=home\_dir)  
> .tox\py310\lib\site-packages\mne\utils\config.py:184: in get\_config\_path  
> val = op.join(\_get\_extra\_data\_path(home\_dir=home\_dir),  
> .tox\py310\lib\site-packages\mne\utils\config.py:330: in \_get\_extra\_data\_path  
> if op.isdir(op.join(os.getenv(‘APPDATA’), ‘.mne’)):  
> C:\hostedtoolcache\windows\Python\3.10.9\x64\lib\ntpath.py:104: in join  
> path = os.fspath(path)  
> E TypeError: expected str, bytes or os.PathLike object, not NoneType

I do not get this error in Linux or Mac however. Maybe someone encountered something similar?

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [January 27, 2023, 1:54pm UTC](https://mne.discourse.group/t/error-importing-mne-on-windows/6254/2 "2023-01-27T13:54:27Z")

</div>

Looks like a bug to me. Apparently the `APPDATA` environment variable is not set and we don’t handle this case gracefully. As a workaround, can you try to set the variable to an arbitrary value?

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![timonmerk](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/timonmerk/32/276_2.png) [@timonmerk](https://mne.discourse.group/u/timonmerk)\
**Post date:** [January 27, 2023, 3:48pm UTC](https://mne.discourse.group/t/error-importing-mne-on-windows/6254/3 "2023-01-27T15:48:51Z")

</div>

Thanks for the quick response!

Tbh I am not sure how I can change that, since I get this error from an automatic testing framework via tox with github workflows…

When I import mne on my local Windows machine it does not come up.

Also, I came across this commit some time ago implementing the check for APPDATA:

> <https://github.com/mne-tools/mne-python/commit/99f8f0400563c2c49934349b3cf0aaf8167ed0bc>
>
> \* Update utils.py
> 
> change APPDATA to USERPROFILE
> 
> \* address comments

It might be that “USERPROFILE” instead of APPDATA would need to be checked?

For completeness here my github workflow .yml file:

```python
name: Tests
on:
  push:
    branches:
      - main
      - '**'
    paths-ignore:
      - 'docs/**'
      - '*.md'
      - '*.rst'
      - '*.txt'
  pull_request:
    branches:
      - main
      - '*.x'
    paths-ignore:
      - 'docs/**'
      - '*.md'
      - '*.rst'
      - '*.txt'
jobs:
  tests:
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - {name: 3.10 Windows, python: '3.10', os: windows-latest, tox: py310}
          - {name: 3.10 Mac, python: '3.10', os: macos-latest, tox: py310}
          - {name: 3.10 Linux, python: '3.10', os: ubuntu-latest, tox: py310}
          - {name: Lint, python: '3.10', os: ubuntu-latest, tox: lint}
          - {name: Typing, python: '3.10', os: ubuntu-latest, tox: typing}
          - {name: Style, python: '3.10', os: ubuntu-latest, tox: style}
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python }}
      - name: update pip
        run: |
          python -m pip install -U pip
      - name: get pip cache dir
        id: pip-cache
        run: echo "::set-output name=dir::$(pip cache dir)"
      - name: cache pip
        uses: actions/cache@v3
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('requirements/*.txt') }}
          restore-keys: pip|${{ runner.os }}|${{ matrix.python }}
      - run: pip install tox
      - run: tox -e ${{ matrix.tox }}

```

with the corresponding tox.ini file:

```python
[tox]
env_list =
   py3{10, 11}
 
skip_missing_interpreters = true
isolated_build = true

[testenv]
description = install pytest in a virtual environment and invoke it on the tests folder
deps =
    pytest>=7
    pytest-sugar
commands = pytest tests {posargs}
[tox]
env_list =
   py3{10, 11}
 
skip_missing_interpreters = true
isolated_build = true

[testenv]
description = install pytest in a virtual environment and invoke it on the tests folder
deps =
    pytest>=7
    pytest-sugar
commands = pytest tests {posargs}

```

I know its a super specific error, I checked on the github website [Workflow syntax for GitHub Actions - GitHub Docs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) that their os is Windows Server 2022. So one option might be simple to not use the workflow on Windows, since MacOS and Linux are passing fine.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [January 27, 2023, 3:52pm UTC](https://mne.discourse.group/t/error-importing-mne-on-windows/6254/4 "2023-01-27T15:52:57Z")

</div>

You can set environment variables in GH actions until we fix the bug:

> **[Variables - GitHub Docs](https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow)**
>
> GitHub sets default variables for each GitHub Actions workflow run. You can also set custom variables for use in a single workflow or multiple workflows.

---

<div class="post-metadata">

**Author:** ![timonmerk](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/timonmerk/32/276_2.png) [@timonmerk](https://mne.discourse.group/u/timonmerk)\
**Post date:** [January 27, 2023, 4:29pm UTC](https://mne.discourse.group/t/error-importing-mne-on-windows/6254/5 "2023-01-27T16:29:48Z")

</div>

Thanks again. Unfortunately though, the environment variable was not detected like that: [Update tests.yml · neuromodulation/py\_neuromodulation@6059a2c · GitHub](https://github.com/neuromodulation/py_neuromodulation/actions/runs/4026293277/jobs/6920617676)

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [January 31, 2023, 9:15pm UTC](https://mne.discourse.group/t/error-importing-mne-on-windows/6254/6 "2023-01-31T21:15:54Z")

</div>

I started working on a fix: [Fix configuration folder discovery on Windows by hoechenberger · Pull Request #11441 · mne-tools/mne-python · GitHub](https://github.com/mne-tools/mne-python/pull/11441)

Would you care to try this branch and see if it fixes your issue? You can install it via

```python
pip install -U https://github.com/hoechenberger/mne-python/archive/refs/heads/config-dir-windows.zip

```
