I have set up miniconda3 python 3.7 with various packages on macOS 10.15.3. For a project, I want to run some Python code from Stata 16.1.
By default, Stata is running the python executable installed by homebrew, @ /usr/local/bin/python3. As I have set up python packages in the miniconda python environment, I have 'set python_exec /usr/local/miniconda3/bin/python3'. Python starts fine and works without any issues.
Starting python from stata with the 'python'-command results in a prompt where basic operation work.
To test the environment a bit better, I try to run 'samplepy.do' from https://www.stata.com/new-in-stata/python-integration/
This fails with the following error message:
Apparently 'from sklearn.svm import SVC' fails from within the Stata python environment. Issuing the command in the interpreter of '/usr/local/miniconda3/bin/python3' run from the command line, does not result in an issue.
Why is the symbol _main not found when run from within the Stata python environment?
By default, Stata is running the python executable installed by homebrew, @ /usr/local/bin/python3. As I have set up python packages in the miniconda python environment, I have 'set python_exec /usr/local/miniconda3/bin/python3'. Python starts fine and works without any issues.
Starting python from stata with the 'python'-command results in a prompt where basic operation work.
To test the environment a bit better, I try to run 'samplepy.do' from https://www.stata.com/new-in-stata/python-integration/
This fails with the following error message:
Code:
. python: ----------------------------------------------- python (type end to exit) ------------------------------------------ >>> from sfi import Data >>> import numpy as np >>> from sklearn.svm import SVC Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/miniconda3/lib/python3.7/site-packages/sklearn/__init__.py", line 82, in <module> from .base import clone File "/usr/local/miniconda3/lib/python3.7/site-packages/sklearn/base.py", line 20, in <module> from .utils import _IS_32BIT File "/usr/local/miniconda3/lib/python3.7/site-packages/sklearn/utils/__init__.py", line 27, in <module> from .fixes import np_version File "/usr/local/miniconda3/lib/python3.7/site-packages/sklearn/utils/fixes.py", line 18, in <module> import scipy.stats File "/usr/local/miniconda3/lib/python3.7/site-packages/scipy/stats/__init__.py", line 384, in <module> from .stats import * File "/usr/local/miniconda3/lib/python3.7/site-packages/scipy/stats/stats.py", line 179, in <module> from scipy.spatial.distance import cdist File "/usr/local/miniconda3/lib/python3.7/site-packages/scipy/spatial/__init__.py", line 102, in <module> from ._procrustes import procrustes File "/usr/local/miniconda3/lib/python3.7/site-packages/scipy/spatial/_procrustes.py", line 11, in <module> from scipy.linalg import orthogonal_procrustes File "/usr/local/miniconda3/lib/python3.7/site-packages/scipy/linalg/__init__.py", line 195, in <module> from .misc import * File "/usr/local/miniconda3/lib/python3.7/site-packages/scipy/linalg/misc.py", line 5, in <module> from .blas import get_blas_funcs File "/usr/local/miniconda3/lib/python3.7/site-packages/scipy/linalg/blas.py", line 215, in <module> from scipy.linalg import _fblas ImportError: dlopen(/usr/local/miniconda3/lib/python3.7/site-packages/scipy/linalg/_fblas.cpython-37m-darwin.so, 2): > Symbol not found: _main Referenced from: /usr/local/miniconda3/lib/python3.7/site-packages/scipy/linalg/_fblas.cpython-37m-darwin.so Expected in: flat namespace in /usr/local/miniconda3/lib/python3.7/site-packages/scipy/linalg/_fblas.cpython-37m-darwin.so (24 lines skipped) -------------------------------------------------------------------------------------------------------------------- r(7102);
Why is the symbol _main not found when run from within the Stata python environment?
Comment