-2

I have a requirement to run my code in python virtual environment, for that I am trying to active the virtual environment through the python script only.

But getting error as: /bin/sh: 1: source: not found

cmd = "source ./nnvm_ndk_tools_env/bin/activate"
process = subprocess.Popen(cmd, stdout=PIPE, shell=True)
Above commands I have added in below script and run the script
python test.py

Output:
source ./nnvm_ndk_tools_env/bin/activate
/bin/sh: 1: source: not found

Can anyone please reply? I have to active the virtual env through python script only.

2

1 Answer 1

0

Hi Firstly you have to install virtualenv then create a virtual environment activate that Virtual Environment and then install all python packages you want in that virtual env. Like below

pip install virtualenv
virtualenv myenv

then a virtual env is created in your directory go to that directory

cd myenv
cd Scripts

then simply run a file 'activate'

activate

you can install your packages here Let me know if you still find problem

Sign up to request clarification or add additional context in comments.

2 Comments

It is encountered with error as "activate: command not found".
You will find activate.bat in Scripts folder. just type activate.bat there if you still find error post a screen shot

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.