Announcement

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

  • Python Error on Stata 18

    Hi Everyone,

    I am using Stata 18 on Windows 11 and am looking to run python code on the program however Stata is unable to recognize python and gives the following errors:

    Code:
    . python query
    minimum Python version required is 2.7
    r(111);
    
    . python search
    minimum Python version required is 2.7
    r(111);
    
    . set python_exec "C:\Python312\python.exe"
    failed to set the specified Python version.
    Unable to find the shared library.
    r(601);

    Click image for larger version

Name:	Screenshot 2024-07-29 120933.png
Views:	1
Size:	14.8 KB
ID:	1760076

    Python even appears in the environment:

    Click image for larger version

Name:	Screenshot 2024-07-29 121411.png
Views:	1
Size:	8.1 KB
ID:	1760077


    I installed Python with a custom path and checked the option where it says to add to PATH as mentioned in the Stata blog by Chuck as well.

    Will be great if anyone from the community or Stata support can assist.

    Thanks.

  • #2
    Much of this looks correct. I don't think you have a problem with your environment variables or your python path. The set python_exec command would give you a file not found error if the python executable wasn't where you said it is.

    You might start with Sergiy's advice from this thread: Double check to make sure the python architecture (whether it is 32 or 64 bit) matches the Stata architecture. If both installations are on the same architecture then your python installation might be corrupt. You might try reinstalling python regardless.

    I notice that the python side of the interface lists IPython as a dependency. If none of the above works, I might try installing anaconda python rather than stock python if you haven't already. Anaconda is probably what you want for statistics work anyway.

    Python 3.12 came out last year and should be compatible with Stata 18. I notice some people online have had luck fixing this issue by downgrading their python version. I'd be willing to bet this actually fixes the issue because they either had an architecture mismatch or corrupt installation that they inadvertently fixed. Still, if all else fails you can try downgrading to python 3.10.

    Comment


    • #3
      Thanks Daniel Schaefer, I installed the 64 bit version of Python for my 64 bit Stata 18 SE as also mentioned by Sergiy Radyakin and a bit confused as to why this is happening. I recently installed Python 3.9 as well and received the same exact error. Not just that, I uninstalled Stata and Python completely then starting by installing Python first before reinstalling Stata, still same error.

      I will give Anaconda a go again however, I installed that too in my attempt.

      Comment

      Working...
      X