Announcement

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

  • Using anaconda python in Stata

    Hello!
    I'm working on a MacBook M2 machine, with MacOS 14.6. I want to access my anaconda python distribution located in /opt/anaconda3/ from Stata 17.0

    In stata python search does not see any anaconda environment, but only

    Python environments found:
    /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/Current/bin/python3
    /usr/bin/python3

    When I set exec with

    python set exec /opt/anaconda3/envs/envforstata/bin/python

    and then I run python within stata I get the following error

    ​​​​​​dlopen(/opt/anaconda3/envs/envforstata/lib/libpython3.8.dylib, 0x0009): tried: '/opt/anaconda3/envs/envforstata/lib/libpython3.8.dylib ' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/anaconda3/envs/envforstata/lib/libpython3.8.dylib' (no such file), '/opt/anaconda3/envs/envforstata/lib/libpython3.8.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
    failed to load the shared library /opt/anaconda3/envs/envforstata/lib/libpython3.8.dylib.
    r(7100);


    (I've tried with different python versions and always got a similar error)

    If on the terminal I run arch, I get
    arm64
    as expected

    Any idea? many thanks in advance
    Lorenzo




  • #2
    I am a windows user, and cannot test this, but it seems you have incompatible architecture: Stata expects arm64 Python, but get x86-64 Python (have 'x86_64', need 'arm64e' or 'arm64'). Thus, your env needs packages for your architecture. The problem is related to Anaconda, and not Stata, so you might try other forums if you dont get any solution here (and see Statalist FAQ 8 on cross-posting).

    Alternatives:
    1. Not using conda: macOS installers on www.python.org support both x86-64 and arm64.
    2. Anaconda: First, make sure your Anaconda installation is up to date. Then, see post on stackoverflow.
    3. Try native alternatives to Anaconda: make a fresh install of one of
    miniconda Apple M1 64-bit
    miniforge OS X arm64
    NB: having both Anaconda and the alternative installed might create problems.
    Then, create env with arm64 Python.
    PS. Using conda, best practice is not to set path, so use Stata -set python_exec- to set full path to the Python.exe in the env to be used.

    (And, use a newer version of Python https://devguide.python.org/versions)

    Comment


    • #3
      Hi Bjarte, many thanks. I thought as well I had a wrong version of Anaconda, but this is not the case. It is arm64. And Anaconda is the distro I always use for my python programming and it works perfectly. It would be hard to renounce to anaconda now. Anyway, thanks a lot for your time and hints.

      Comment

      Working...
      X