imp, os, sys modules not found. MacBook M3 Pro chip.

Hi,

After installing AFNI on my MacBook with the M3 Pro chip and running some commands I noticed that I keep getting a consistent set of errors pertaining to the fact that some modules cannot be found. As such, I reinstalled my system several times followed up by trying the AFNI system check command, but I always ended up getting the following error:

% afni_system_check.py -check_all
Traceback (most recent call last):
File "/Users/myname/abin/afni_system_check.py", line 9, in
from afnipy import module_test_lib
File "/Users/myname/abin/afnipy/module_test_lib.py", line 43, in
import imp, os, sys
ModuleNotFoundError: No module named 'imp'.

This is indeed the error that I get when running other commands, such as afni_proc.py and would really appreciate anyone's help. I asked chatGPT but its suggestion did not resolve my issue.

Thank you!

I am having the same error and would love to know the solution.

Oh right, I forgot to make an update for this. The imp module was removed in python 3.12 , so I have to make a workaround for that. I had planned to make an update for this before now, let me take a look...

  • rick
2 Likes

If you're working under a conda environment, you can choose an earlier version of python for that environment to avoid this problem. Or just wait a few minutes for Rick to fix it.

2 Likes

Hey,

really appreciate all of your replies!

@rickr, thank you for being so keen to help out.

I have found a way to work around it, so if anyone needs it, I set up a virtual environment using pyenv with python 3.8.10 – a version that still supports imp module:

zsh shell

pyenv install 3.8.10 # Installs python 3.8
pyenv global 3.8.10 #Sets it as a global python version
pyenv local 3.8.10 # Sets the local Python version for the directory
python -m venv afni_env # Creates a virtual environment named 'afni_env'
source afni_env/bin/ # activates the virtual environment

Follow by running the script that showed the errors. Modify to fit your directory structure/needs

@dglen the option with conda works as well, thank you.

Hi Rudy,

Thanks a lot for the details.

But I put in an update last night that should be ready right now. Go ahead and give it a try if you have a chance, and then you will not need to mess around with a virtual environment.

Of course 3.8 is okay, but hopefully this will be easier in the long run.

Thanks!

  • rick
1 Like