Search code examples
pythoncondapyenv

pyenv+conda doesn't install packages


I am trying to install packages using conda but nothing happens. conda doesn't find numpy:

$ python -c "import numpy"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'

But when I try to install numpy using conda I just get:

$ conda install numpy
Collecting package metadata: done
Solving environment: done

# All requested packages already installed.

And there is no way to force conda to install it anyway:

$ conda install --force-reinstall numpy
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: {HOME}/.pyenv/versions/miniconda3-latest

  added / updated specs:
    - numpy



Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

Is there a solution to make conda really install packages? Or do I really have to uninstall everything and install everything again? Or is there even a solution to install python (using mkl) that is less horrible than conda?


My environment is set up (using pyenv), to use the conda installation:

$ which python
{HOME}/.pyenv/shims/python

and e.g.

$ python -c "import tqdm; print(tqdm.__file__)"
{HOME}/.pyenv/versions/miniconda3-latest/lib/python3.6/site-packages/tqdm/__init__.py

Solution

  • tl;dr

    conda install -f, conda install --force-reinstall don't do anything, manually remove cache, e.g. rm -rf {CONDA_LOCATION}/pkgs/{PACKAGE_NAME}* followed by conda install {PACKAGE_NAME}.


    I finally found a reasonable hack to force conda to install packages. conda keeps a cache which can be found using conda info

    $ conda info
    ...
    package cache : {HOME}/.pyenv/versions/miniconda3-latest/pkgs
                    {HOME}/.conda/pkgs
    

    Just remove everything related to the packages you want to install from the cache:

    rm -rf {HOME}/.pyenv/versions/miniconda3-latest/pkgs/numpy*
    

    (consider making backup befor performing such radical steps). Afterwards conda can install the packages normally:

    $ conda install numpy
    Collecting package metadata: done
    Solving environment: done
    
    ## Package Plan ##
    
      environment location: {HOME}.pyenv/versions/miniconda3-latest
    
      added / updated specs:
        - numpy
    
    
    The following packages will be downloaded:
    
        package                    |            build
        ---------------------------|-----------------
        numpy-base-1.15.4          |           py36_2         6.1 MB  intel
        ------------------------------------------------------------
                                               Total:         6.1 MB
    
    The following NEW packages will be INSTALLED:
    
      numpy-base         intel/linux-64::numpy-base-1.15.4-py36_2
    
    
    Proceed ([y]/n)? y
    
    
    Downloading and Extracting Packages
    numpy-base-1.15.4    | 6.1 MB    | ################################################################################################################################################################### | 100% 
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done