Software⏱️ 2 min read📅 2026-06-03

How to Fix: Getting a 'source: not found' error when using source in a bash script

Troubleshoot source not found error in bash script

Quick Answer: Check if the virtualenv installation is correct and ensure that the activate file exists at $env_name/bin/activate. If not, try running virtualenv with --system-site-packages flag to fix the issue.

You are getting a 'source: not found' error when using source in a bash script because the virtual environment path is incorrect or the activate file is not executable. To fix this, you can try one of the following methods:

✅ Method 1: Check Virtual Environment Path

  • Verify that the virtual environment path is correct by checking the output of the virtualenv command:
virtualenv --verbose $env_name

Check if the activate file is executable by running the following command:

chmod +x $env_name/bin/activate

✅ Method 2: Use Absolute Path to Activate Virtual Environment

  • Try using the absolute path to activate the virtual environment:
source $env_name/bin/activate

Alternatively, you can add the following line to your bashrc file to set the PATH variable and allow source to find the activate file:

export PATH=$env_name/bin:$PATH

💡 Conclusion

By following these steps, you should be able to resolve the 'source: not found' error and successfully activate your virtual environment.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions