Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX: nimble test fails: Importing the multiarray numpy extension module failed; caused by missing pyInitLibPath #176

Open
timotheecour opened this issue Oct 20, 2020 · 0 comments

Comments

@timotheecour
Copy link
Contributor

timotheecour commented Oct 20, 2020

I'm on OSX.

Testing Python executable: python2
Testing Python executable: python3
Testing Python executable: python2
Traceback (most recent call last):
  File "tests/tnimfrompy.py", line 128, in <module>
    s.testPyFromNim()
nimpy.Exception: Unexpected error encountered: <type 'exceptions.ImportError'>:
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: cannot import name multiarray

stack trace: (most recent call last)
/private/var/folders/ll/dtd6ksrn50n3xkdy4y61tf_80000gn/T/nimblecache/nimscriptapi.nim(165, 16)
/Users/timothee/git_clone/nim/nimpy/nimpy_43710.nims(88, 11) testTask
/Users/timothee/git_clone/nim/nimpy/nimpy_43710.nims(78, 14) runTests
/Users/timothee/git_clone/nim/Nim_devel/lib/system/nimscript.nim(260, 7) exec
/Users/timothee/git_clone/nim/Nim_devel/lib/system/nimscript.nim(260, 7) Error: unhandled exception: FAILED: python2 tests/tnimfrompy.py [OSError]
??? compiler msg initiated here [MsgOrigin]
       Tip: 1 messages have been suppressed, use --verbose to show them.
     Error: Exception raised during nimble script execution

note

  • also fails with similar error with:NIMPY_PY_EXES=python3 nimble test
  • adding
# in nimpy/tests/tpyfromnim.nim
import timn/nimpy_utils
initNimpy()

with:

# in timn/nimpy_utils
proc initNimpy*() =
  var isInit{.threadvar.}: bool
  if not isInit:
    # defined via https://github.com/yglukhov/nimpy/issues/171
    let libpython = findLibpython("python3")
    # dbg libpython
    pyInitLibPath(libpython)
    isInit = true

and then NIMPY_PY_EXES=python3 nimble test
makes it work

so we really need to add auto-discovery (calling pyInitLibPath), ie address #171

note 2

NIMPY_PY_EXES=python2 nimble test (or nimble test) still don't work, for other reasons:

Testing Python executable: python2
Testing Python executable: python2
Traceback (most recent call last):
  File "tests/tnimfrompy.py", line 2, in <module>
    import nimfrompy as s
TypeError: PyModule_AddObject() needs module as first arg

but that's a lesser problem given deprecation of python2

note 3

after that, CI should add OSX (currenly it's linux only AFAIK)

@timotheecour timotheecour changed the title nimble test fails: Importing the multiarray numpy extension module failed. Most nimble test fails: Importing the multiarray numpy extension module failed; caused by missing pyInitLibPath Oct 20, 2020
@timotheecour timotheecour changed the title nimble test fails: Importing the multiarray numpy extension module failed; caused by missing pyInitLibPath OSX: nimble test fails: Importing the multiarray numpy extension module failed; caused by missing pyInitLibPath Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant