Closed timotheecour closed 5 years ago
I think nimpy is using python3 on your system. It tries to find the most recent python version. To verify that:
import nimpy
echo pyImport("sys").path
and compare it to
python -c "import sys; print(sys.path)"
doesn't look like it:
nim c -r main.nim
import nimpy
echo pyImport("sys").path
['/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Users/timothee/Library/Python/2.7/lib/python/site-packages', '/Users/timothee/homebrew/lib/python2.7/site-packages', '/Users/timothee/homebrew/Cellar/numpy/1.15.4_2/libexec/nose/lib/python2.7/site-packages', '/Users/timothee/homebrew/Cellar/protobuf/3.6.1.3/libexec/lib/python2.7/site-packages', '/Users/timothee/homebrew/opt/llvm_tim/lib/python2.7/site-packages', '/Users/timothee/homebrew/lib/python2.7/site-packages', '/Users/timothee/homebrew/Cellar/numpy/1.15.4_2/libexec/nose/lib/python2.7/site-packages', '/Users/timothee/homebrew/opt/llvm_tim/lib/python2.7/site-packages']
python -c "import sys; print(sys.path)"
['', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Users/timothee/homebrew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Users/timothee/Library/Python/2.7/lib/python/site-packages', '/Users/timothee/homebrew/lib/python2.7/site-packages', '/Users/timothee/homebrew/Cellar/numpy/1.15.4_2/libexec/nose/lib/python2.7/site-packages', '/Users/timothee/homebrew/Cellar/protobuf/3.6.1.3/libexec/lib/python2.7/site-packages', '/Users/timothee/homebrew/opt/llvm_tim/lib/python2.7/site-packages', '/Users/timothee/homebrew/lib/python2.7/site-packages', '/Users/timothee/homebrew/Cellar/numpy/1.15.4_2/libexec/nose/lib/python2.7/site-packages', '/Users/timothee/homebrew/opt/llvm_tim/lib/python2.7/site-packages']
Ok. And python -c 'import numpy'
doesn't raise any errors?
it doesn't
Googling around this problem is vaguely described as a conflict between the system python and brew python. Could it so happen that python
binary comes from the system python, and the dylib loaded by nimpy comes from brew, or the other way around?
Could it so happen that python binary comes from the system python, and the dylib loaded by nimpy comes from brew, or the other way around?
If so, it might be connected to https://github.com/yglukhov/nimpy/issues/46
If so, it might be connected to #46
Yeah, but not really, because any installed python dll should work. And this is just a system (brew?) bug.
update: this is related to https://stackoverflow.com/questions/47658596/strange-mixing-of-system-homebrew-python-with-lldb this works:
PATH=/usr/bin:$PATH nimble test
but not ideal obviously as it has other side effects
Well I don't see a way to fix this properly. Even with python selection functionality in place, there still remains the possibility to hit this. Because, let me repeat it, I treat this as an os/environment issue. But feel free to prove me wrong.
python -c 'import matplotlib; print(matplotlib.__version__)'
2.2.2possibly related to this: https://github.com/timotheecour/vitanim/pull/5#issuecomment-457740937 /cc @Vindaar
diagnostic
let o = pyLib.PyImport_ImportModule(moduleName)
fails