Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ImportError after specifying set python_exec in Python integration

    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
    Last edited by Sifat Raquib; 22 Aug 2022, 16:37.
Working...
X