pipcondacrewai

Installing a package using PIP inside a Conda env


Pip will not install a package into my conda env. This is what I have done:

conda create -n myenv python=3.10
conda activate myenv

All good, terminal shows myenv is active.

I am trying to install a non-conda or forge package - called crewai. Therefore I have to use pip.

Running which -a pip returns.

/home/a_shipley/anaconda3/envs/crewai-flows/bin/pip
/home/a_shipley/.local/bin/pip
/usr/bin/pip
/bin/pip

which -a python returns,

/home/a_shipley/anaconda3/envs/crewai-flows/bin/python
/usr/bin/python
/bin/python

python -m pip install crewai==0.70.1 returns already installed.

Requirement already satisfied: crewai==0.70.1 in /home/a_shipley/.local/lib/python3.10/site-packages (0.70.1)

crewai is already installed in my home -> pip list crewai is not present in anaconda or my local myenv env.

And, running the right pip:

(crewai-flows) a_shipley@ShipleyAI:~/Conda_env/crewai-flows-crash-course$        /home/a_shipley/anaconda3/envs/crewai-flows/bin/pip install crewai==0.70.1
Requirement already satisfied: crewai==0.70.1 in /home/a_shipley/.local/lib/python3.10/site- packages (0.70.1)

Solution

  • I am not very familiar with Conda but I am guessing running conda activate myenv activates the Python virtual environment managed by Conda. Does your prompt change in this fashion?

    prompt $ conda activate myenv
    (myenv) prompt $
    

    Now just run,

    (myenv) prompt $ which python
    

    This should tell you the path of the current python command,

    path/to/myenv/bin/python
    

    Take a note if something like myenv appears in the path. This is your hint that you are being shown the path to your conda managed environment.

    Now just run,

    path/to/myenv/bin/python -m pip install crewai==0.70.1
    

    And check with,

    path/to/myenv/bin/python -m pip list
    

    Hope this helps.