Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which environment (as in environment variables) does PyCall use? #698

Closed
goretkin opened this issue Jun 16, 2019 · 2 comments
Closed

Which environment (as in environment variables) does PyCall use? #698

goretkin opened this issue Jun 16, 2019 · 2 comments

Comments

@goretkin
Copy link
Contributor

I can set an environment variable as follows:

PyCall.PyDict(PyCall.pyimport("os").environ)["SOURCE_DATE_EPOCH"] = "0"

Using ENV in Julia did not work. I would like to understand which environment the python interpreter is in. As far as I understand, there isn't a separate process for the interpreter, so I am surprised there is a separate environment.

@stevengj
Copy link
Member

stevengj commented Jun 17, 2019

See the Python docs for os.environ:

This mapping is captured the first time the os module is imported, typically during Python startup as part of processing site.py. Changes to the environment made after this time are not reflected in os.environ, except for changes made by modifying os.environ directly.

So, when PyCall is started, it gets a copy of Julia's environment. Subsequently modifying ENV (i.e. the actual environment) will not change os.environ (Python's copy).

@goretkin
Copy link
Contributor Author

Ah, thanks for the explanation. So this is specific to how python handles environment variables. Unintuitive, but certainly documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants