-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Ability to use PYTHONPATH from user bash_profile in macOS application #14843
Comments
Hi @mrclary, Yes! This is a really good idea. Have you tested this option to see if this is working with the mac app? |
I haven't tested it yet, though I think it should be fairly easy to incorporate. However, now I'm wondering if this shouldn't be part of a larger improvement to add the ability to set/get other environment variables for the Consoles, not just PYTHONPATH. For example, similar to the PYTHONPATH Manager, a Console Environment Manager that gives the user the option to "import" environment variables from their For background, my company has systems setup that require data analysts to have certain environment variables set (~100 variables!), including PYTHONPATH. Conventionally, these are all set and managed in the user's
To retrieve the environment variables is fairly straightforward: import os
import subprocess as sp
out, err = sp.Popen('[[ -e /etc/profile ]] && source /etc/profile; '
'[[ -e ~/.bash_profile ]] && source ~/.bash_profile; '
'printenv',
shell=True, stdout=sp.PIPE, stderr=sp.PIPE).communicate()
variables = {}
for kv in out.decode().strip().split('\n'):
k, v = kv.split('=')
variables.update({k: v}) |
I don't know how environment variables are handled on Windows systems, or whether the Spyder executable has any of the same issues as the macOS application. So consider the previous comment as a brainstorm. |
This looks right, can you please test it and let me know if it works as expected? Right now probably the information will not appear in Spyder's python path manager, but you can test it in the consoles. If it works, could you help us implement this in two PRs?
Please be careful because if any weird |
@steff456, I don't think I understand your comment. If we limit the scope to just PYTHONPATH, then I can extract that from the We cannot control what is in the I will submit a PR, though and we can go from there. |
Perfect! I know weird things happen if |
@steff456, What should the user experience be? Another possibility is that this feature and PYTHONPATH Manager could be mutually exclusive.
Or maybe this preference determines whether PYTHONPATH from What do you think? |
@steff456 @ccordoba12, I think I prefer #14918 over #14853.
|
@steff456, should this issue also be moved over to the ux repo for discussion? |
It would be nice to be able to import the PYTHONPATH from a user's
bash_profile
to replace/append to Spyder's PYTHONPATH Manager.The issue is that many users may require setting PYTHONPATH in their
bash_profile
for other purposes, but the macOS application cannot make use of this, thus users may be required to manage PYTHONPATH in two locations: inbash_profile
as well as in Spyder's PYTHONPATH Manager.The text was updated successfully, but these errors were encountered: