Hello

If I set a certain environment's executable for python, initialize it and import a package installed within that environment, I get no error.

However, now if I run a do-file that tries to run a certain python script, with the same executable and user path defined, I am getting ImportError.

To illustrate:

The following code block runs with no issue.
Code:
# set python executable and user path in stata.
set python_exec /path/to/exec
set python_userpath /path/to/package_dir

# initialize python
python

# import pandas
import pandas
The following does not:
Code:
# set python executable and user path in stata.
set python_exec /path/to/exec
set python_userpath /path/to/package_dir

do "/path/to/do/file"
I get
Code:
ImportError: No module named pandas
The do file has
Code:
!python script.py
script.py only has one line - import pandas as pd