Saturday, November 13, 2021

[SOLVED] activate virtualenv in git bash using pycharm on windows

Issue

I have activated git bash instead of command prompt (cmd) in Pycharm. Whenever I try to activate the virtualenv, which is named venv, I face with two problems:

  1. After I execute source venv/Scripts/activate, face with the following error:
bash: basename: command not found
()

which (I think) means that it doesn't recognize source command.

  1. Running ./venv/Scripts/activate has also another problem:
You must source this script: $ source ./venv/Scripts/activate
()

What should I do?

pycharm terminal

PS: Also <exact-directory>/venv/Scripts/activate works properly in cmd.


Solution

There is a python package called pipenv.

It can be installed easily by entering pip install pipenv command. Then start using it by executing the following command:

pipenv shell

It automatically creates a new virtual environment.

Freezing the packages is as simple as:

pipenv lock -r > requirements.txt


Answered By - Mostafa Ghadimi