Common Mistakes and Fixes for Installing Python Environments

Common Mistakes and Fixes for Installing Python Environments

Pyenv common installation error fix

I am learning about Agentic AI, Today I finished my implementation of crewAI. CrewAI is framework for developing the agent which without human intervention are executing the task.

When you are coming back to development after long time python environment is a good waking up call. I stuck on repetative mistake - I am installing the package and it throw module not found error to me.

If you are seasoned developer you the your coming hours aren’t gonna be friendly. So first flag - The package is installed in global space and now it start something like this

(toollearning) username@mac devops_crew > python -V

3.8

Old? So,

(toollearning) username@mac devops_crew > pyenv local 3.11.10

python -V

3.11.10

pip install google-auth-oauthlib

Still module not found?

Activate Your Virtual Environment Properly

Instead of relying on pyenv shims, activate your venv manually:

source /path/to/your/venv/bin/activate

Directly Use pyenv local

If you are using pyenv virtualenv, you can set it for your project:

pyenv local toollearning

Now, which python should return:

/Users/username/.pyenv/versions/toollearning/bin/python

Install the missing dependency:

pip install google-auth-oauthlib

Sometime it still show error?

Then check if pip is correctly linked:

which pip

Force Install pip in .venv

Run:

python -m ensurepip --default-pip

Then upgrade pip inside .venv:

python -m pip install --upgrade pip

Now verify:

which pip

✅ It should now return:

/Users/username/devops_crew/.venv/bin/pip

Now Python and pip both pointing to same virtual environment and all installation of packages will never throw module not found error!

Also when you are working with crewAI

\>crewai run

Tip 💡:

It will create virtual environment .venv for you so you do need to create virtual environment and need to just make sure your python and pip is pointing to the .venv it has created.