Announcement

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

  • Stata-Python Interface: Python module not working

    Hello,

    I am trying to use the Stata-Python Interface, but for some reason my Stata is unable to find the Python sklearn module from my computer. I use Python 3.7.4, and when I try to import the sklearn module on Python (i.e. instead of from Stata), it works without an error, but when I try to import the same module on my Stata-Python Interface, an error pops up and the error message is "module sklearn not found". Perhaps my Stata is not pointing at the right python? How can I fix this issue?

    Thank you,

    PS: I tried uninstalling and than re-installing the sklearn module multiple times, but this doesn't seem to fix this issue. When I do this, I can import the sklearn module on my Python without any problem, but I can't import the same module on Stata.


  • #2
    What is the output of

    Code:
    python query
    from Stata.

    And where is the Python 3.7.4 which works with sklearn located? To find out, in your Python 3.7.4,

    Code:
    import sys
    print(sys.path)
    Last edited by Hua Peng (StataCorp); 18 Nov 2019, 14:05.

    Comment


    • #3
      Hello,
      Below are the outputs:

      Code:
      >>>  python query
      2.7/lib/python2.7/config/libpython2.7.dylib
      
      # in python
      >>> import sys
      >>> print(sys.path)
      Users/dominiquebourget/opt/anaconda3/lib/python3.7
      so I am assuming this saying that the Stata is pointing at a wrong Python. How can I adjust this?

      Thank you,

      Comment


      • #4
        The output of help python includes the following advice.

        Set which version of Python to use

        python set exec pyexecutable [, permanently]
        ...
        pyexecutable specifies the executable of a Python installation, such as "C:\Program Files\Python36\python.exe", "/usr/bin/python", "/usr/local/bin/python", "~/anaconda3/bin/python", or "~/anaconda/bin/python".

        Comment


        • #5
          Thank you!

          Comment

          Working...
          X