Stack Overflow Asked by Mostafa Ghadimi on January 1, 2022
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:
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.
./venv/Scripts/activate
has also another problem:You must source this script: $ source ./venv/Scripts/activate
()
What should I do?
PS: Also <exact-directory>/venv/Scripts/activate
works properly in cmd.
just write this command line in your virtual environment file:
. Scripts/activate
Answered by zeki kadiroğlu on January 1, 2022
The correct answer appears to be in the comment added by @Touten.
This is actually just a display issue - the venv is activated, but it doesn't display the usual (venv) tag in the terminal. This can be confirmed by calling which python
and seeing that is displays the venv's python.
Alternatively, you can follow the answer by @Nikki-Aaron to disable automatically activating the venv. Then you can activate it using source venv/Scripts/activate
and it will show the tag in the terminal.
Answered by Further Reading on January 1, 2022
There is a setting in File > Settings > Terminal for "Activate virtualenv". This works for cmd shell, but seems not to work with bash in Windows 10. If I uncheck that setting, 'source venv/Scripts/activate' activates as expected.
Answered by Nikki on January 1, 2022
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 on January 1, 2022
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP