-
Notifications
You must be signed in to change notification settings - Fork 34
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
[Bug] sys.path
is not accessible when subprocess is called in pynml.execute_command_in_dir_with_realtime_output
#440
Comments
sys.path
is not accessible when subprocess is called in pynml.execute_command_in_dir_with_realtime_output
Thanks for that. We should also check all the other functions that call subprocess to see if this issue persists there too. I'll take a look ASAP. |
@adampdp : would you have a code snippet that I can use to reproduce this please? I tried this snippet, and it does find the neuroml module, so it does seem to look at the different folders in import sys
import os
from pyneuroml.runners import execute_command_in_dir_with_realtime_output
env = os.environ
print(f'PATH is: {env["PATH"]}')
print()
print(f"sys.path is: {sys.path}")
print()
command = "python -c 'import neuroml; print(neuroml.__version__); print(neuroml.__file__); '"
execute_command_in_dir_with_realtime_output(command, directory=".") |
Hi, It only happens when env is set, if env is None as it would be in this code snippet subprocess uses the sys.path for env I believe. It means if env is set to some path and passed you also need to manually add sys.path to it if you want to import other modules not on the path passed in env. |
|
Describe the bug
in pynml.execute_command_in_dir_with_realtime_output(),
sys.path is not accessible when subprocess is called. env['PYTHONPATH'] in subprocess overrides sys.path.
sys.path should be added to the env['PYTHONPATH'] before passing to subprocess for correct module import. See the link below:
python/cpython#105889
The text was updated successfully, but these errors were encountered: