Activate virtual environment in windows using Git-Bash [duplicate] - python

This question already has answers here:
Can not activate a virtualenv in GIT bash mingw32 for Windows [duplicate]
(7 answers)
Closed 3 years ago.
I am trying to activate virtual environment in windows using Git-Bash
I used this line and this works fine
virtualenv project1_env
Then when trying this line to activate
.\project1_env\Scripts\activate
I got bash: .project1_envScriptsactivate: command not found
I tried several tries to make it works but it didn't
Note that this line works on command prompt with no problem
So my problem is with Git-Bash on windows
Thanks advanced for help

On Windows10, you could go in the directory of your virtualenv where the Scripts folder is placed then enter the below command
source ./Scripts/activate

Related

my pip install in python shell is not working [duplicate]

This question already has answers here:
Why does "pip install" inside Python raise a SyntaxError?
(7 answers)
Closed 1 year ago.
so i am a beginner python programmer when i was trying to do a chatbot as a training but the problem is when i wrote pip install chatterbot in the python shell they give me an syntax error and when i searched on the net and on YOUTUBE .all the videos have the same solution that's going to the environnement variables then going to path and add some files address but i had the files address of python but it still not working . i am working in windows 10 and python 3.9 (64bit)this is the photo of the problem and thanks for answering me.the syntax error
You're trying to run a pip command in the Python interpreter, which only understands Python code.
If you're on Windows, open Command Prompt (cmd) and run your pip command from there.
Make sure you use pip installs in terminals. So on PyCharm use the terminal tab on the bottom of the main window.

How to use Pycharm venv's local library when running from a Cmd line [duplicate]

This question already has an answer here:
Dyld Error Message when launching PyCharm
(1 answer)
Closed 1 year ago.
let us consider the following PyCharm project which has its own env
My goal is to run the test "test_translator_dispatcher_new_format.py" from a bash. How to instruct the cmd to use that venv and its local library?
open command prompt from current (project) directory
Then activate the virtual environment using this command:
venv\Scripts\activate
then change directory using this command, in your case directory name is tests:
cd <directory_name>
Run python file using this command:
python test_translator_dispatcher_new_format.py

Source command error in Windows 10 on cmder [duplicate]

This question already has answers here:
Issue with virtualenv - cannot activate
(33 answers)
Closed 2 years ago.
I am trying to use this command
source .venv\bin\activate
but I get this error
'source' is not recognized as an internal or external command,
operable program or batch file.
can some one help me with this
1.use cmd rather that cmder
2.to create env use "python -m venv <name_of_your_env>"
3.after this check if it created the environment or no by using "dir"
4.to activate the environment use "<name_of_your_env>\Scripts\activate.bat"
5.to deactivate the environment use "deactivate"
6.to delete the environment completely use "rmdir <name_of_your_env> /s"
You can also refer to this video if my explanation is not clear: https://youtu.be/APOPm01BVrk

Set specific interpreter for venv using cli [duplicate]

This question already has answers here:
Can existing virtualenv be upgraded gracefully?
(6 answers)
Closed 2 years ago.
Is it possible to set a specific interpreter (Python 3.7 or Python3.8) without using any IDE but only using command line commands?
I know that is possible using Pycharm, Anaconda or other else, but I would know the command.
Thanks and good day
If you use conda or mini conda, you can set up separate virtual environment with the benefit of selecting a different interpreter version and different packages. I suggest you familiarise yourself with conda and miniconda, and how to start an environment, run scripts etc from terminal with their guides. Resources below:
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

How do I activate a virtual environment in Windows 7 [duplicate]

This question already has answers here:
Trying to create a virtualenv in python and activate it
(3 answers)
Closed 3 years ago.
I currently need to work on a flask project, to do that, I need to activate a virtual environment for my project. Virtual environment has already been installed at Python37\Scripts folder, but each time I want to activate the virtual environment by running C:\Users\user\Desktop\flask-intro\venv\Scripts>activate. <flask-intro is my project folder>. I get an error that says 'activate' is not recognized as an internal or external command, operable program, or batch file. What could be the issue.
To Create and activate a Virtual Env for project on windows, navigate to your project directory on your command line window and run the following commands
To create - python -m venv your-env-name
To activate - your-env-name\Scripts\activate.bat
You don't need to provide full path to the script, it's enough to use like this: \path\to\env\Scripts\activate and it should be activated.
Also you can check this page for more details about it: https://virtualenv.pypa.io/en/latest/userguide/#activate-script

Categories