Announcement

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

  • Stata and Python 3.13 virtual environment

    I have no problem using Stata 18IC with Python without an environment in Windows
    Code:
    . python query
    
        Python Settings
          set python_exec      C:\Python313\python.exe
          set python_userpath  
    
        Python system information
          initialized          no
          version              3.13.0
          architecture         64-bit
          library path         C:\Python313\python313.dll
    
    . python:
    ----------------------------------------------- python (type end to exit) ------------------------------------------------------------------------------------------------------------------------
    >>> a = 1
    >>> b = 2
    >>> c = a + b
    >>> c
    3
    >>> end
    ----------------------------------------------------------
    However when I try to use it with a virtual environment Stata shuts down as soon as I execute python:

    I have activated the virtual environment using Powershelll prior to starting the Stata session.

    Code:
    PS D:\StataP> .\venv313\Scripts\activate
    (venv313) PS D:\StataP>
    Code:
        Python Settings
          set python_exec      D:\StataP\venv313\Scripts\python.exe
          set python_userpath  
    
        Python system information
          initialized          no
          version              3.13.0
          architecture         64-bit
          library path         C:\Python313\python313.dll
    . python:
    I would be gratful for any pointers as to what I am doing wrong.

    Thank you.
    Janet

  • #2
    If someone with more knowledge of the topic is reading this: We're facing the exact same issue.

    We have tested with Windows 11 against multiple python versions (3.9, 3.11 and 3.12) and on multiple machines. The described behaviour is the same everywhere: Stata shuts down without an error message.

    When attaching a debugger to the Stata process, we could extract the following output:

    The thread 15880 has exited with code 0 (0x0).
    'StataSE-64.exe' (Win32): Loaded 'C:\Windows\System32\wtdccm.dll'.
    'StataSE-64.exe' (Win32): Loaded 'C:\Program Files\Python311\python311.dll'.
    Fatal Python error: failed to get the Python codec of the filesystem encoding
    Any help would be greatly appreciated!

    Comment


    • #3
      I am likewise eager to hear of a resolution to this. Python 3.13.0, Stata 18.0 MP on Windows 10 Pro.

      Comment


      • #4
        I have the exact same issue

        Comment


        • #5
          I have sent a query to Technical Support and will post any replies / solutions.
          Janet

          Comment


          • #6
            Hi everyone,

            I reached out to the STATA support and got help. The following steps fixed the problem for me:

            1. Close all Stata and open a new Stata.
            2. Click the menu Help --> Annoucements to open the Annoucements dialog.
            3. Click the bottom-left icon and check "Disable future announcements" and then close the dialog.
            4. Close Stata and reopen it and then try to set the Python executable from Stata.

            Comment


            • #7
              Originally posted by Stephan Probst View Post
              The following steps fixed the problem for me . . .
              Yep, that works for me, too, although I didn't install a local Python executable in the virtual environment and so didn't need to do anything with python set exec. (I've installed only packages in the virtual environment and so had to only add their path via python set userpath.)

              Thank you for the follow-up.

              Comment


              • #8
                It works for me as well. I would never of thought of disabling Annoucements. I am still in dialog with TechSupport.

                Thank you for the solution.
                Janet

                Comment

                Working...
                X