Activating virtual environment environment - python-3.x

please for a while now i've been trying to activate virtual environment for my windows 7 machine; I've run commands like env\Scripts\activate where env is the installed virtual environment folder in the project, but each time i run the command, it gives me an error like: activate is not recognized as an internal or external command, operable program or batch file. Please what could be the problem, what should i do?

Do you have activate.bat inside Scripts folder? If yes, run that. If not, delete everything and run python -m venv env again and let me know what happens. Please note that you may change env to whatever you want.

Here it is (just google it, there are a lot of post explaining that):
https://programwithus.com/learn-to-code/Pip-and-virtualenv-on-Windows/

Related

Setting up and activating virtual environment

So, I've been trying to activate my virtual environment in VScode so I could open my Django manage.py and run the server, but for some reason it doesn't seem to activate in my bash terminal. And after running it, I get a "did you forget to activate your virtual environment?". What am I missing here?
In the env folder, there should be an "activate.bat" script, that you can execute to activate your venv.
I think you should open bash in the existing directory and run Scripts\activate
I'd also like to confirm which of the virtual environment you are making use of.

Cant Install pipx or Brownie for Python

I am very new with coding and was following along with these youtube videos and quickly realized something wasn't right, so I did some trouble shooting and couldn't figure it out.
When I tried to download pipx on VS Code I get this error
Python3 : The term 'Python3' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
I changed my environment variables, changed app execution aliases, and still nothing
I figured I'd check to see if python was working through VS Code and I get the same error
I tried downloading python through Microsoft store to see if that would help but nope.
Not sure what to do
I was having the same issue for a while even though I added the following directory to the environment variable and system variable. C:\Users\username\AppData\Roaming\Python\Python310\site-packages\pipx
What worked for me was adding the following directory to the environment variable and system variable. (c:\users\username.local\bin)
The directory (c:\users\username.local\bin) will be used to create the virtual environments.
I also found this when typing (python -m pipx ensurepath) which returned:
C:\Users\username\.local\bin has been been added to PATH, but you need to open a new terminal or re-login for this PATH change
to take effect.
C:\Users\username\AppData\Roaming\Python\Python310\Scripts has been been added to PATH, but you need to open a new terminal or
re-login for this PATH change to take effect.
The (C:\Users\username.local\bin) path was the only thing I did not manually enter into my environment variable and system variable, so thought I should give that a try and it worked.

VS Code cannot activate virtual environment with env\Scripts\activate.bat

I've been looking at all sorts of sources and I cannot make it happen that a virtual environment is created. I have serious problems with the Terminal. Whereas in the other sources by just typing the commands as instructed like \env\Scripts\activate.bat works perfectly, for me I just get an error saying it is not recognized as a name of a cmdlet nor a function nor a script file nor an executable program, see screenshot. It's a nightmare. I also e.g. changed the settings.json as in some suggested methods, but no luck.
enter image description here
In the virtual environment Scripts folder there are 2 activate scripts: activate.bat and activate.ps1.
.bat files aren't recognized in the terminal.
Try running just env\Scripts\activate.

How to run virtual environment from shell script?

I am trying to setup my project environment from a shell script on ubuntu so that I can skip basic setup every time.
I use my virtual environmet cv using the command workon cv.
But I am having trouble doing so using a shell script. I tried the the script
#!/bin/bash
workon cv
But I get the error
workon: command not found
I try to list all the venv I have
pran#pran-HP-65-Notebook-PC:~$ lsvirtualenv
cv
==
virtual-py2
===========
Also, I thought of locating it
(cv) pran#pran-HP-65-Notebook-PC:~/.virtualenvs$ l
cv/ postdeactivate preactivate* prermvirtualenv*
get_env_details* postmkproject* predeactivate virtual-py2/
initialize postmkvirtualenv premkproject*
postactivate postrmvirtualenv* premkvirtualenv*
How can I do it?
You cannot execute workon command outside of Python virtual environment.
If you are interested, check out this article that will walk you through all of the steps required to set up your virutal env.
If it is not what you need then please clarify your requirements for a project environment.
I found the solution:
My venv was located in .virtualenvs. So, I put the command in the bash file start.sh (meant to be executed before working on my project).
#start.sh
source ~/.virtualenvs/cv/bin/activate
And run it using
$ source start.sh
It works perfectly 👍

Cannot run node.js program in command prompt

Arch-noobie here. When I try to run a node.js program in windows command prompt by stating its location, it will invariably say "[stated location] is not recognized as an internal or external command, operable program or batch file."
In all answers to similar questions, in all node.js manuals, it is assumed you can just run a node.js file by calling it from its location. There will always be the suggestion of trying some "hello world" example BEFORE establishing a server and so on.
Even if I clean the command prompt with "prompt $ cmd", and then write the whole location manually, I get the same message.
Can anybody help me with this? Thanks in advance.
By default, your node.js should be installed in C:\Program Files\nodejs location. Check for it.
Next, look for environment variables to be set at C:\Program Files\nodejs\bin
You can follow this link to check for the PATH and environment variables.
Then, restart your system. It should start working.
make sure you are typing node NOT npm

Resources