Closed maltissimo closed 4 years ago
Hi Matteo,
How did you install xraylib exactly? You shouldn't have had to do that, since it should already have been installed as part of OASYS.
I followed the instructions on the wiki page.
So there might be some issues with the OASYS install then...
How did you install OASYS? As part of a miniconda/anaconda environment or did you use virtualenv? In the latter case: how did you install the python3 interpreter?
I installed OASYS with pip (python3 -m pip install OASYS), and python3 via brew
If it may provide some clues: from terminal, I start python, and get into the python 2.7 environment. xraylib is imported with no issues. Repeating with python3, opens the python 3.7 environment. From there, I cannot do an "import xraylib".
I assume you installed xraylib via brew as well?
Could you please copy-paste the output of brew list -v xraylib
?
I actually compiled from code with the instructions I found in the wiki. Here is the output of the command you suggested:
mac-altissimo2:site-packages teo$ brew list -v xraylib find /usr/local/Cellar/xraylib/3.3.0 -not -type d -print /usr/local/Cellar/xraylib/3.3.0/INSTALL_RECEIPT.json /usr/local/Cellar/xraylib/3.3.0/bin/xraylib /usr/local/Cellar/xraylib/3.3.0/.brew/xraylib.rb /usr/local/Cellar/xraylib/3.3.0/Changelog /usr/local/Cellar/xraylib/3.3.0/AUTHORS /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib-crystal-diffraction.h /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib-radionuclides.h /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib-defs.h /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib-auger.h /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib.mod /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib-lines.h /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib-nist-compounds.h /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib-shells.h /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib-parser.h /usr/local/Cellar/xraylib/3.3.0/include/xraylib/xraylib.h /usr/local/Cellar/xraylib/3.3.0/README /usr/local/Cellar/xraylib/3.3.0/TODO /usr/local/Cellar/xraylib/3.3.0/lib/pkgconfig/libxrlf03.pc /usr/local/Cellar/xraylib/3.3.0/lib/pkgconfig/libxrl.pc /usr/local/Cellar/xraylib/3.3.0/lib/libxrl.a /usr/local/Cellar/xraylib/3.3.0/lib/libxrl.7.dylib /usr/local/Cellar/xraylib/3.3.0/lib/libxrlf03.a /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/xraymessages.py /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/xraylib_np.cpython-37m-darwin.so /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/pycache/xraylib.cpython-37.pyc /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/pycache/xraylib.cpython-37.opt-1.pyc /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/pycache/xrayhelp.cpython-37.pyc /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/pycache/xraymessages.cpython-37.pyc /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/pycache/xraymessages.cpython-37.opt-1.pyc /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/pycache/xrayhelp.cpython-37.opt-1.pyc /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/xraylib.py /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/xrayhelp.py /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/site-packages/_xraylib.cpython-37m-darwin.so /usr/local/Cellar/xraylib/3.3.0/lib/libxrlf03.7.dylib /usr/local/Cellar/xraylib/3.3.0/lib/libxrlf03.dylib /usr/local/Cellar/xraylib/3.3.0/lib/libxrl.dylib /usr/local/Cellar/xraylib/3.3.0/share/xraylib/xraydoc.txt /usr/local/Cellar/xraylib/3.3.0/share/xraylib/xraybanner.txt /usr/local/Cellar/xraylib/3.3.0/share/xraylib/xrayhelp.txt /usr/local/Cellar/xraylib/3.3.0/share/xraylib/xrayfunc.txt mac-altissimo2:site-packages teo$
thank you for your help, by the way.
I think you have at least two xraylib installations then: one compiled from source, and one installed using xraylib.
Using the brewed python: the following should work
/usr/local/bin/python3 -c "import xraylib"
Could you also please copy paste the output of brew info xraylib
?
Ok, so I tried the python3 -c command but I had a ModuleNotFoundError in the output.
the output of brew info xraylib is: brew info xraylib tschoonj/tap/xraylib: stable 3.3.0 Library for interactions of X-rays with matter https://github.com/tschoonj/xraylib /usr/local/Cellar/xraylib/3.3.0 (40 files, 34.6MB) * Built from source on 2019-07-22 at 15:20:11 From: https://github.com/tschoonj/homebrew-tap/blob/master/xraylib.rb ==> Dependencies Build: swig ✔, cython ✔ Required: gcc ✔, numpy ✔ Recommended: python ✔ Optional: fpc ✘, perl ✘, python@2 ✔, ruby ✘ ==> Options --with-fpc Build with fpc support --with-perl Build with perl support --with-python@2 Build with python@2 support --with-ruby Build with ruby support --without-python Build without python support mac-altissimo2:site-packages teo$
Did you invoke the brewed python3 interpreter with its full path /usr/local/bin/python3
? This matters in case you have multiple python3 interpreters on your system...
yes, I did, and I also had a look into the site-packages directory of python 3.7, xraylib is not present there.
what output do you get for:
brew link --overwrite --dry-run xraylib
mac-altissimo2:local teo$ brew link --overwrite --dry-run xraylib Warning: Already linked: /usr/local/Cellar/xraylib/3.3.0 To relink: brew unlink xraylib && brew link xraylib mac-altissimo2:local teo$
Given your answer here, and your last reply, the following file should exist: /usr/local/lib/python3.7/site-packages/xraylib.py
. Can you confirm this?
Can you also print the output of /usr/local/bin/python3 -c 'import sys ; print(sys.path)'
Thank you, I am taking up a lot of your time. In any event, the xraylib.py is present in the folder you mentioned.
/usr/local/bin/python3 -c 'import sys ; print(sys.path)' ['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages', '/Users/teo/PyCharm-GitHub-data/OASYS1-ELETTRA-Extension', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scikit_image-0.15.0-py3.7-macosx-10.9-x86_64.egg', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Pillow-6.1.0-py3.7-macosx-10.9-x86_64.egg', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/networkx-2.3-py3.7.egg', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/imageio-2.5.0-py3.7.egg', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PyWavelets-1.0.3-py3.7-macosx-10.9-x86_64.egg', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/decorator-4.4.0-py3.7.egg'] mac-altissimo2:bin teo$
Aha, now I see what's going on... the python3 interpreter you are using does not look like it has been installed by brew. I get the following output:
$ /usr/local/bin/python3 -c 'import sys ; print(sys.path)'
['', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages', '/usr/local/Cellar/numpy/1.16.4/libexec/nose/lib/python3.7/site-packages']
Where did you get this executable from? What output do you get for: brew info python
brew info python python: stable 3.7.4 (bottled), HEAD Interpreted, interactive, object-oriented programming language https://www.python.org/ /usr/local/Cellar/python/3.7.1 (4,031 files, 62.3MB) Poured from bottle on 2018-12-05 at 14:48:43 /usr/local/Cellar/python/3.7.4 (3,865 files, 60MB) Poured from bottle on 2019-07-22 at 15:18:29 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb ==> Dependencies Build: pkg-config ✘ Required: gdbm ✔, openssl ✔, readline ✔, sqlite ✔, xz ✔ ==> Options --HEAD Install HEAD version ==> Caveats Python has been installed as /usr/local/bin/python3
Unversioned symlinks python
, python-config
, pip
etc. pointing to
python3
, python3-config
, pip3
etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run brew install python@2
You can install Python packages with
pip3 install
See: https://docs.brew.sh/Homebrew-and-Python ==> Analytics install: 440,505 (30 days), 1,184,737 (90 days), 4,421,920 (365 days) install_on_request: 215,260 (30 days), 573,509 (90 days), 2,437,266 (365 days) build_error: 0 (30 days)
If I was you I would try reinstalling python:
brew uninstall python -f
brew install python
ok will do. Thank you for your time, I really appreciated it.
Hi Tom, so I did reinstall Python 3.7.4, and following suit, I did: brew uninstall xraylib -f brew install tschoonj/tap/xraylib
Still, in the site-packages directory of python 3.7 xraylib is not present, which means Python3/7 doesn't see it. If I look into the python2.7/site-packages directory, I do find xraylib (.py, .pyc, .pyo, _np.la, _np.so) and a few others. Really not sure how to proceed from this point.
Can you give the output of /usr/local/bin/python3 -c 'import sys ; print(sys.path)'
again please?
Also of brew list xraylib
here they are:
/usr/local/bin/python3 -c 'import sys ; print(sys.path) ' ['', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages', '/Users/teo/PyCharm-GitHub-data/OASYS1-ELETTRA-Extension'] mac-altissimo2:site-packages teo$ /usr/local/bin/python3 -c 'import sys ; print(sys.path)' ['', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages', '/Users/teo/PyCharm-GitHub-data/OASYS1-ELETTRA-Extension']
$ brew list xraylib /usr/local/Cellar/xraylib/3.3.0/bin/xraylib /usr/local/Cellar/xraylib/3.3.0/include/xraylib/ (10 files) /usr/local/Cellar/xraylib/3.3.0/lib/libxrl.7.dylib /usr/local/Cellar/xraylib/3.3.0/lib/libxrlf03.7.dylib /usr/local/Cellar/xraylib/3.3.0/lib/pkgconfig/ (2 files) /usr/local/Cellar/xraylib/3.3.0/lib/python3.7/ (11 files) /usr/local/Cellar/xraylib/3.3.0/lib/ (4 other files) /usr/local/Cellar/xraylib/3.3.0/share/xraylib/ (4 files)
Thats looks all good.
Does /usr/local/lib/python3.7/site-packages/xraylib.py
still exist? If so, /usr/local/bin/python3 -c 'import xraylib'
should work...
it is no longer there.
Try:
brew unlink xraylib
brew link --overwrite xraylib
I think that did it. Python 3 can now import xraylib, and so does PyCharm. thank you Tom.
no worries, glad I could help. Python can be a real mess sometimes.
My personal recommendation is to use an Anaconda environment for this kind of things and not to rely on Homebrew.
Thank you for the tip and all the help. I will look into Anaconda and see whether it makes sense on OSX. At the moment I'm running with "If it ain't broke, don't fix it" kind of approach... Thanks again, have a great night.
Hello,
I am working with Oasys and the synchrotron suite, I am using Pycharm for development. Pycharm uses Python 3.7, but the default Python install on my High Sierra OSX is Python 2.7. Xraylib gets installed in the 2.7 version, so I cannot use it with Pycharm. Is there any way this could be addressed?
best regards
Matteo