pythoncondasplinter

ModuleNotFoundError or ImportError When Installing Python Packages to Conda Env That Require Pip


While this may be pretty straightforward, I want to share a solution to an issue I was having since I did not have a problem with this until now.

Essentially I was having trouble running splinter in my conda virtual environment. I first activated my environment conda activate PythonData. Then I tried to run conda install splinter which failed, then conda install -c metaperl splinter which also failed.

I then moved onto using pip, so I went to the documentation and ran pip install splinter.

The installation said it was successful, but after restarting the kernel I was still receiving the same error.

See below the solution :)


Solution

  • I looked through my anaconda bins and did not find the package. Then I realized when I try to install a second time (after ensuring my environment was indeed activated), I saw it was installed in my usr folder - not my anaconda3 folder.

    Therefore, I had to run pip uninstall splinter to remove it, and then did the following:

    conda install pip to first install pip (which I used previously with no errors so this is puzzling, but such is life)

    conda info to find my active environment path

    After copying the active environment path similar to the following /anaconda/envs/venv_name, I was able to run the installation like this:

    /anaconda/envs/venv_name/bin/pip install splinter

    And then viola! It worked.