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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.