Announcement

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

  • Can't import scipy.stats

    Hello,

    I'm running Spyder Python 3.3.6 from Stata/IC 16.1 for Mac (64-bit Intel):

    . python query
    ------------------------------------------------------------------------------------------------------
    Python Settings
    set python_exec /users/jprenderg/opt/anaconda3/bin/python
    set python_userpath

    Python system information
    initialized yes
    version 3.7.4
    architecture 64-bit
    library path /Users/jprenderg/opt/anaconda3/lib/libpython3.7m.dylib

    I can import scipy just fine. But when I try "from scipy import stats" I get the following error:

    Traceback (most recent call last):
    File "/users/jprenderg/desktop/python/pyex2.py", line 8, in <module>
    from scipy import stats
    File "/users/jprenderg/opt/anaconda3/lib/python3.7/site-packages/scipy/stats/__init__.py", line 379, in <module>
    from .stats import *
    File "/users/jprenderg/opt/anaconda3/lib/python3.7/site-packages/scipy/stats/stats.py", line 180, in <module>
    import scipy.special as special
    File "/users/jprenderg/opt/anaconda3/lib/python3.7/site-packages/scipy/special/__init__.py", line 641, in <module>
    from ._ufuncs import *
    ImportError: dlopen(/users/jprenderg/opt/anaconda3/lib/python3.7/site-packages/scipy/special/_ufuncs.cpython-37m-darwin.so, 2): Symbol not found: _main
    Referenced from: /users/jprenderg/opt/anaconda3/lib/python3.7/site-packages/scipy/special/_ufuncs.cpython-37m-darwin.so
    Expected in: flat namespace
    in /users/jprenderg/opt/anaconda3/lib/python3.7/site-packages/scipy/special/_ufuncs.cpython-37m-darwin.so
    failed to execute the specified Python script file


    Has anyone else experienced this or does anyone know a solution?

    Thanks,
    Joe
    Last edited by Joe Prendergast; 04 May 2020, 16:04.

  • #2
    The following works under Windows:
    Code:
    python:
    import os 
    os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = "C:/Users/scott/Anaconda3/Library/plugins"
    import matplotlib.pyplot as plt
    from scipy import stats
    gaussian = stats.norm(loc=10.0, scale=1.0)
    plt.hist(gaussian.rvs(10000), bins=50)
    plt.show()
    end
    Perhaps this will help:
    https://stackoverflow.com/questions/...-actually-mean

    Comment


    • #3
      Hi Scott:

      This runs fine:

      import os
      os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = "/Users/jprenderg/Anaconda3/plugins"
      import matplotlib.pyplot as plt

      But "from scipy import stats" still produces the same error.

      By the way, how do you get your code to appear in that well-formatted gray block?

      Thanks.


      Comment


      • #4
        You might try Stata tech support.

        If you click on the "Underlined A" it will toggle the Advanced Editor and then the "#" button will wrap [CODE] tags around selected text

        Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	2.2 KB
ID:	1551274

        Comment

        Working...
        X