Title: Conda reports that a package is installed, but it appears not to be
Tags: python,linux,anaconda,conda,spacy

Question: I'm trying to install spaCy using conda but i still getting the error
ModuleNotFoundError: No module named 'spacy'

Things i already tried:

re installing conda.
delete and create a new environment.

OBS:

the environment is active.
running Linux.
if i run !conda list i can see to spaCy package.

I thing the problem is about the installation directory, but i'm not sure how to solve it.
some output:
    import sys
    print(sys.prefix)
    output: /usr

  active environment : Texto
    active env location : /home/arancium/.conda/envs/Texto
            shell level : 1
       user config file : /home/arancium/.condarc
 populated config files : /etc/conda/condarc
                          /home/arancium/miniforge3/.condarc
                          /home/arancium/.condarc
          conda version : 23.1.0
    conda-build version : not installed
         python version : 3.10.9.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.37=0
                          __linux=6.2.8=0
                          __unix=0=0
       base environment : /home/arancium/miniforge3  (writable)
      conda av data dir : /home/arancium/miniforge3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/arancium/.conda/pkgs
       envs directories : /home/arancium/.conda/envs
                          /home/arancium/miniforge3/envs
               platform : linux-64
             user-agent : conda/23.1.0 requests/2.28.2 CPython/3.10.9 Linux/6.2.8-zen1-1-zen arch/rolling glibc/2.37
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

# conda environments:
#
Texto                 *  /home/arancium/.conda/envs/Texto
base                     /home/arancium/miniforge3

sys.version: 3.10.9 | packaged by conda-forge | (main...
sys.prefix: /home/arancium/miniforge3
sys.executable: /home/arancium/miniforge3/bin/python
conda location: /home/arancium/miniforge3/lib/python3.10/site-packages/conda
conda-build: None
conda-env: /home/arancium/miniforge3/bin/conda-env
user site dirs: ~/.local/lib/python3.10

CIO_TEST: <not set>
CONDA_DEFAULT_ENV: Texto
CONDA_EXE: /home/arancium/miniforge3/bin/conda
CONDA_PREFIX: /home/arancium/.conda/envs/Texto
CONDA_PROMPT_MODIFIER: (Texto) 
CONDA_PYTHON_EXE: /home/arancium/miniforge3/bin/python
CONDA_ROOT: /home/arancium/miniforge3
CONDA_SHLVL: 1
CUDA_PATH: /opt/cuda
CURL_CA_BUNDLE: <not set>
LD_PRELOAD: <not set>
PATH: /home/arancium/.conda/envs/Texto/bin:/home/arancium/miniforge3/condabin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>
XDG_SEAT_PATH: /org/freedesktop/DisplayManager/Seat0
XDG_SESSION_PATH: /org/freedesktop/DisplayManager/Session1

Answer: The Python interpreter you are using is not the one from your active conda environment.
Lets ensure that you are using the correct Python interpreter from your active conda environment.
first activate your conda env conda activate Texto then check your python interpreter which python it should be something like /home/arancium/.conda/envs/Texto/bin/python if not make sure that make sure your PATH environment variable is correctly set. You can update it like that export PATH="/home/arancium/.conda/envs/Texto/bin:$PATH" Now run your script with the correct interpreter python your_script.py
If that still dont work use the full path like this /home/arancium/.conda/envs/Texto/bin/python your_script.py