Announcement

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

  • How can I get -python query- to give current Python version information?

    I recently updated my installation of Python to Version 3.10.7 for a project, but Stata's python query still reports the older patch level.

    .ÿ
    .ÿversionÿ17.0

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿlocalÿline_sizeÿ`c(linesize)'

    .ÿsetÿlinesizeÿ80

    .ÿ
    .ÿpythonÿquery
    --------------------------------------------------------------------------------
    ÿÿÿÿPythonÿSettings
    ÿÿÿÿÿÿsetÿpython_execÿÿÿÿÿÿC:\ProgramÿFiles\Python\python.exe
    ÿÿÿÿÿÿsetÿpython_userpathÿÿ

    ÿÿÿÿPythonÿsystemÿinformation
    ÿÿÿÿÿÿinitializedÿÿÿÿÿÿÿÿÿÿno
    ÿÿÿÿÿÿversionÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.10.4
    ÿÿÿÿÿÿarchitectureÿÿÿÿÿÿÿÿÿ64-bit
    ÿÿÿÿÿÿlibraryÿpathÿÿÿÿÿÿÿÿÿC:\ProgramÿFiles\Python\python310.dll

    .ÿ
    .ÿpython:
    -----------------------------------------------ÿpythonÿ(typeÿendÿtoÿexit)ÿ------
    >>>ÿ
    >>>ÿimportÿplatform
    >>>ÿ
    >>>ÿprint(platform.python_version())
    3.10.7
    >>>ÿ
    >>>ÿ#ÿimportÿsys;ÿprint(sys.version)
    ...ÿ#ÿgivesÿsameÿversion,ÿalongÿwithÿGitHubÿtagÿetc.
    >>>ÿend
    --------------------------------------------------------------------------------

    .ÿ
    .ÿsetÿlinesizeÿ`line_size'

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .


    (Patch levels above are manually colored red for visibility.)

    I get the correct information calling Python directly from the operating system's command prompt, i.e., python --version and I get the same incorrect information when I call Stata's python query after initializing Python within Stata, say, after running the Python code above (not shown).

    It appears that I'm not alone in experiencing inconsistencies in the patch level that python query reports, for example, see this post in an ongoing thread. The installation path there is censored and so I'm guessing that it is local to the user, but mine is a single installation for all users (see path information given by Stata above), and so that doesn't seem to matter.

    I assume that it's cosmetic (at least I hope that it's only cosmetic), but it is a little awkward in documenting things via Stata log files in the project folder.

    Does anyone know how to flush the obsolete information from whatever python query calls?

  • #2
    Hi Joseph Coveney,

    You can type

    Code:
    python set exec pyexecutable, permanently
    ​​​​
    to reset your Python environment to be 3.10.7 in a fresh Stata before initializing it. The permanently option will let Stata remember your setting next time.

    Comment


    • #3
      Thank you Zhao Xu (StataCorp) for your quick reply. Your recommendation did the trick.

      Comment

      Working...
      X