Reputation: 995
I am setting a project path to some env variable like PROJECT_HOME by us using os.environ like this:
os.environ['PROJECT_HOME'] = os.getcwd()
so I can use %cd $PROJECT_HOME/abc/xyz
in later cell
However, the system return this:
[Errno 2] No such file or directory: '${PROJECT_HOME}/abc/xyz'
Is there a way to use env variable in %cd?
Upvotes: 1
Views: 1000
Reputation: 995
I just realized the magic %cd
could access python variable. Therefore it could be done like this:
import os
PROJECT_HOME = os.getcwd()
%cd {PROJECT_HOME}
Having said that, the answer by Daniel is the right answer to the question because I asked how to %cd
a path containing an environment variable.
Upvotes: 2