From the website ( https://channel9.msdn.com/Blogs/jsturtevant/Setting-up-Project-Oxford-for-Python-on-Windows ) at about 4:27, the author opens the activate.bat file by using code .env\Scripts\activate.bat
, however, when I run that, they'll show bash: code: command not found. I have also tried with vscode .env\Scripts\activate.bat
to no avail.
I remember that from: python.exe file not found; creating "virtual environment" you suggested using source .env/bin/activate ; however, I soon realize that it only creates venv and does not open the activate.bat file on VSCode for me to edit the API code in, When I force open it using the Code-OSS, it shows an empty file. However, when I try to open it using notepad, it shows the code in it as follows:
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/home/pi/happy-image-tester-django/env"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use if (set -u; : $PYTHONHOME) ; in bash
if [ -n "$PYTHONHOME" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x(env) " != x ] ; then
PS1="(env) $PS1"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
fi
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi
Therefore, may I ask if I can just key in the 3 lines of codes:
line 61: SET “OXFORD-KEY=________”
62
63 :END
into the notepad directly and save it? I believe I cant do that as the file seem to have compressed into the format suitable for raspbian somewhere when the program is installed. Hence, may I know what code I should key in instead to open the bat file properly to be able to edit it? Thank you!!!
<----------------------------------------------------------------------------->
3rd python script (combine.py) from https://stackoverflow.com/questions/31601996/combining-two-python-scripts-to-run-as-one-program:
def code1():
import capture.py
def code2():
import manage.py
code1()
code2()
Upon runninng:
(env) pi@raspberrypi:~/happy-image-tester-django $ OXFORD_KEY=1234567890 python capture.py runserver
Should I do the 1st method above or the 2nd method which is inserting the oxford_key into the combine.py scripts as shown below:
def code1():
import capture.py
def code2():
import manage.py
code1()
OXFORD_KEY=1234567890
code2()
and then runs this directly without having to input the oxford key in the command prompt any longer: (env) pi@raspberrypi:~/happy-image-tester-django $ python capture.py runserver