Search code examples
pythonpython-3.xcondaenvironment

Meaning of this error message python version conflicts


While trying to install package: line-profiler-pycharm, I install it using pip inside my conda environment called wcs. But when I try to run it, I get the following error:

 22:01  Error running 'prep_network': Could not 
do Profile Lines execution because the
python package 'line-profile-pycharm' is not 
installed to Python 3.8 (wcs): Python 3.10.5 (/Users/myusername/opt/anaconda3/envs/wcs/bin/python)

Why does it show to python 3.8 and then python 3.10 after the colon :?

I checked the python versions inside my ˜/anaconda3/wcs/bin/python , I can see python 3.11 and python3.10, Python3.8 does not even exist in there.


Solution

  • Type $ which pip and compare with $ which python. They likely come from different places. To avoid the mismatch, prefer $ python -m pip install ...

    Going forward, it would be best to add "line-profiler-pycharm" to your project's environment.yml, and then $ conda env update will properly install it for you.

    If your config gets messed up, it is always harmless to discard the environment (anaconda3/envs/wcs) and use $ conda env update to re-create it from scratch.