Source command error in Windows 10 on cmder [duplicate] - python

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

Related

Can't activate python virtual environment [duplicate]

This question already has answers here:
'virtualenv' won't activate on Windows
(23 answers)
Closed last month.
I'm new to python and have been learning how to use a virtual environment.
I followed the tutorial on youtube and created a virtual environment using this command:
python -m venv venv-testing
and tried to activate it using this command:
venv-testing\Scripts\activate.bat
I expected there was my virtual environment name in brackets that showed it activated, but it did nothing. It also didn't show error.
Can someone explain what exactly happened to me? I use Windows and PowerShell.
Thank you very much☺️
From PowerShell, you don't want to start the .bat.
You can, but that will start a new cmd process, in which your environment will activate, and then it will kill that process again.
Instead, you'll want to start the .ps1, i.e.:
venv-testing\Scripts\activate.ps1
This will activate the environment in your current PowerShell process, and the activation will persist after running the script.
Depending on your system's configuration, just running this may work:
venv-testing\Scripts\activate
But you may want to explicitly run the .ps1 instead, to avoid a situation where what you do works on some systems, but not on others.

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

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

Pip is not recognized in command prompt bu working in Anaconda prompt [duplicate]

This question already has answers here:
'pip' is not recognized as an internal or external command
(40 answers)
Closed 4 years ago.
I know if I add pip path to env variables, this would resolve. But I am not able to find the directory where pip.exe is located.
Attached are the snapshots of working in Anaconda prompt but not working in command prompt.
Add pip path to your environmental variables.
My Computer->Properties->Advanced system settings-> environment variables -> edit path
variable in in the system variables box then append your path with it

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

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

Categories