0

I want to run setenv command through python script, the linux command is as below

setenv MODEL path/to/the/model

I tried using os.environ(), but I couldn't get the right syntax.

note - I'm using python 2.7

3
  • 1
    By setenv, I suppose you're referring to the csh builtin. It's specific to csh and family. Commented Mar 9, 2020 at 16:15
  • Anything you run in a shell you start from Python only works until that shell exits; it won't change the environment of the Python interpreter, or the shell that started the Python interpreter. Commented Mar 9, 2020 at 16:33
  • @WilliamPursell, that's true, but even changing to use POSIX sh syntax, the command in question would still not have the desired effect. Commented Mar 9, 2020 at 16:35

1 Answer 1

0

os.environ isn't a function. Check out the docs: https://docs.python.org/2/library/os.html#os.environ

This question may also be helpful to you: How to set environment variables in Python. If it is, pay attention to the comments on the top answer.

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

1 Comment

Duplicative questions should be closed, not answered. See the "Answer Well-Asked Questions" section of How to Answer, particularly the bullet point regarding questions that "have already been asked and answered many times before".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.