Closed charlesll closed 2 years ago
Hi Charles,
On Wed, Sep 5, 2018 at 2:32 AM Charles Le Losq notifications@github.com wrote:
Hi,
I tried installing Larch using miniconda as well as the bash script on Linux x86-64.
Sorry for the trouble. Could you be more specific about what steps you took?
Do you mean that you installed one environment with miniconda, and then another with "the bash script" or was that one install where you first installed miniconda and then ran "the bash script" on the same environment? Also, which bash script are you referring to?
In both case I end with an error message related to wx when trying to
import larch:
import larch Traceback (most recent call last): File "
", line 1, in File "/home/charles/xraylarch/lib/python3.6/site-packages/larch/init.py", line 28, in from .shell import shell File "/home/charles/xraylarch/lib/python3.6/site-packages/larch/shell.py", line 10, in from .interpreter import Interpreter File "/home/charles/xraylarch/lib/python3.6/site-packages/larch/interpreter.py", line 18, in from . import builtins File "/home/charles/xraylarch/lib/python3.6/site-packages/larch/builtins.py", line 22, in from . import fitting File "/home/charles/xraylarch/lib/python3.6/site-packages/larch/fitting/init.py", line 6, in import wx File "/home/charles/xraylarch/lib/python3.6/site-packages/wx/init.py", line 12, in version = wx.version.VERSION_STRING AttributeError: module 'wx' has no attribute 'version' This implies to me that wx was imported but that it did not have a
__version__
. That's odd. I would ask what version that was, but it seems that will be unknowable ;).
Anyway, that seems like a broken-ish wx to me. I'd like to understand how that happened, so details on the install steps would be helpful.
This issue is solved by installing wxpython with conda.
Should wxpython be added as a dependency?
Maybe... We do try to make wxPython optional, and in fact the error you got comes from code where we test for ImportError, but not AttributeError which is why I think the wx install is broken. We initially wanted to make Larch be able to run on a small-ish, non-graphical system and so without wxPython. I think that is a fine goal, even if we are not meeting it 100%.
OTOH, if using a modern conda environment (as of this year or so), I have no problem requiring that wxPython 4 is required as this is now supported for all Anaconda Python versions. And the conda package for xraylarch does depend on wxpython, and and the single-install bash-script ( xraylarch-0.9.40-Linux-x86_64.sh) should definitely install the wxpython-4.0.1 conda package.
Anyway, that's just to say that I'd like to understand what happened in more detail. Thanks!
--Matt
@charlesll as a follow-up, I found this:
~> bash ~/Downloads/Miniconda3-latest-Linux-x86_64.sh
~> export PATH=/home/newville/miniconda3/bin:$PATH
~> conda install -c gsecars xraylarch
gave me a complete and working system:
~> which xas_viewer
~/miniconda3/bin/xas_viewer
~> xas_viewer
runs fine. Do you get different results?
Hi,
Yes of course. First, this problem was raised when trying to install on Manjaro Linux (rolling release, Arch-based, kernel 4.18).
My first trial was in my go-to conda py36 environment running Python 3.6 / GCC 7.2. I tried to install with conda install -yc GSECARS xraylarch
. The install went fine. Then, going into Python and trying to import larch, I got the wx error message (same with trying to run xas_viewer).
My second trial was to install through the bash command bash xraylarch-0.9.40-Linux-x86_64.sh
after download xraylarch-0.9.40-Linux-x86_64.sh.
Install went OK, but again, running the Python environment from this install resulted in the same error.
I re-tried this morning with a fresh and clean test environment running Python 3.6 and installing with the conda command: same problem occurred.
The problem occurs with wxpython 4.0.0a3-py36_1 GSECARS
Solution is to upgrade wxpython to 4.0.3-py36h76a34b6_0 (latest I guess) with conda. Now I can launch xas_viewer from the terminal in my py36 conda env (nice interface btw!), or call larch in the Python REPL without problem.
Now, I also tried installing larch through conda this morning on Mac OS (latest version), and the install went without trouble. No wxpython problem. However, xas_viewer won't start because of a problem of a function not found in lmfit... more on that later, as I do not have my laptop in the lab right now.
All in all, it seems related to the version of wxpython that is installed during Larch install, which may not be compatible with my setup?
In all cases, thanks for the hard work on this package, it looks great!
@charlesll Thanks very much for the details. It still seems sort of odd to me, but we can definitely deprecate using the wxpython 4.0.0a3 package, which seems like it may be sufficient to avoid the problem.
Larch (especially xas_viewer) definitely needs lmfit 0.9.11, but that too should be included. I'm (again!) not sure why the install isn't picking up the latest package.
No problem! Yes I don't really understand what happened...
For lmfit on Mac OS, it is even stranger. The larch install proceed with downloading and installing 0.9.11... But when I did pip install --upgrade lmfit
, it turns out that 0.9.7 was active and upgraded to 0.9.11 ... I can't understand why... I had no version of lmfit installed on this computer prior to installing larch. In all cases, problem is solved by upgrading to 0.9.11 with pip
On another note: are you interested in Jupyter Notebook examples of the use of Larch? If yes, I could push some to the examples folder at the occasion.
Cheers, Charles.
@charlesll
On another note: are you interested in Jupyter Notebook examples of the use of Larch? If yes, I could push some to the examples folder at the occasion.
Yes, that would be very nice. Having a Larch kernel for Jupyter would also be kinda cool for many uses. It looks like it is probably not too hard, but I have not gone very far into that idea.
Hi @charlesll, Hi @newville
@newville Thanks for your efforts putting this package together. Seems reasonable to add my issue here (?). I have tried installing larch on a Mac running OS Mojave (10.14.2) with mixed results.
Using the MacOS installer I am able to successfully run the XAS_veiwer and Larch_GUI via the desktop shortcuts created during install. There may be some strangeness there but I didn't pay close attention and haven't probed to deeply. I was able to undertake some LCF so at first pass looks good.
When I tried to call larch from the terminal however I get the following error -
larch Traceback (most recent call last): File "/Users/SAJ/anaconda2/bin/larch", line 61, in
import larch File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/init.py", line 28, in from .shell import shell File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/shell.py", line 10, in from .interpreter import Interpreter File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/interpreter.py", line 18, in from . import builtins File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/builtins.py", line 22, in from . import fitting File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/fitting/init.py", line 26, in from lmfit import (Parameter, Parameters, Minimizer, conf_interval, ImportError: cannot import name ufloat
ImportError Traceback (most recent call last)
@fluxmap
@newville https://github.com/newville Thanks for your efforts putting
this package together. Seems reasonable to add my issue here (?). I have tried installing larch on a Mac running OS Mojave (10.14.2) with mixed results.
Using the MacOS installer I am able to successfully run the XAS_veiwer and Larch_GUI via the desktop shortcuts created during install. There may be some strangeness there but I didn't pay close attention and haven't probed to deeply. I was able to undertake some LCF so at first pass looks good.
When I tried to call larch from the terminal however I get the following error -
larch Traceback (most recent call last): File "/Users/SAJ/anaconda2/bin/larch", line 61, in import larch File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/init.py", line 28, in from .shell import shell File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/shell.py", line 10, in from .interpreter import Interpreter File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/interpreter.py", line 18, in from . import builtins File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/builtins.py", line 22, in from . import fitting File "/Users/SAJ/anaconda2/lib/python2.7/site-packages/larch/fitting/ init.py", line 26, in from lmfit import (Parameter, Parameters, Minimizer, conf_interval, ImportError: cannot import name ufloat
This is probably because the installer created an Anaconda Python 3 environment in $HOME/xraylarch, and the desktop icons point to that folder.
The error you're getting from $HOME/anaconda2 environment looks to be a mismatch (that is completely my fault) between lmfit 0.9.12 and larch 0.9.40 (the problem is solved in the github master version of xraylarch, which I hope to release as 0.9.41 in a few days). If you make sure you're using $HOME/anaconda2/bin/python, doing
~> python -m pip install lmfit==0.9.11
should solve that problem.
As I would like to use larch within a Jupyter notebook I abandoned this
approach and tried using larch within my anaconda python 3.6 environment. I have been unsuccessful, receiving a seemingly related but distinct error when trying to import larch in a JupyterLab notebook or Jupyter QtConsole session -
Yes, this would be nice. I believe this can work OK on Linux and Windows, but that there is a real challenge to make this work well with Anaconda Python on MacOS. This challenge is essentially a problem with Anaconda Python on MacOS and wxPython. I'll skip some of the details here, but I think it may be a problem for using larch with jupyter on MacOS. It might not be a small problem, but I agree that it is worth trying to fix.
ImportError Traceback (most recent call last)
in ----> 1 import larch
~/anaconda2/envs/python_3/lib/python3.6/site-packages/larch/init.py in 26 from .site_config import show_site_config 27 from .symboltable import Group, SymbolTable, isgroup ---> 28 from .shell import shell 29 from .inputText import InputText 30 from .utils import Closure, fixName, nativepath, get_homedir
~/anaconda2/envs/python_3/lib/python3.6/site-packages/larch/shell.py in 8 9 from .symboltable import SymbolTable ---> 10 from .interpreter import Interpreter 11 from .site_config import history_file, show_site_config 12 from .version import version, date, make_banner
~/anaconda2/envs/python_3/lib/python3.6/site-packages/larch/interpreter.py in 16 import six 17 ---> 18 from . import builtins 19 from . import site_config 20 from .symboltable import SymbolTable, Group, isgroup
~/anaconda2/envs/python_3/lib/python3.6/site-packages/larch/builtins.py in 20 from . import inputText 21 from . import site_config ---> 22 from . import fitting 23 from .larchlib import parse_group_args, LarchExceptionHolder 24 from .symboltable import isgroup
~/anaconda2/envs/python_3/lib/python3.6/site-packages/larch/fitting/init.py in 24 25 import lmfit ---> 26 from lmfit import (Parameter, Parameters, Minimizer, conf_interval, 27 ci_report, conf_interval2d, ufloat, correlated_values) 28
ImportError: cannot import name 'ufloat' This program needs access to the screen. Please run with a Framework build of python, and only when you are logged in on the main display of your Mac.
Note: Same error message whether I am working off the laptop screen or external monitor. Any suggestions on how to resolve one or both of these issues would be welcomed gladly.
This is the combination of the two different problems. The 'ufloat' is due to using lmfit > 0.9.11 and larch = 0.9.40 release. This will be fixed soon, but you can also revert to lmfit=0.9.11 for now. The "framework" message when tyring to use jupyter on MacOS is a bigger problem.
Boom! Your suggested fix worked. Larch now launches from the terminal. Thanks for the background on the "framework" problem, I run a windows VM (incidentally this is where I keep Demeter) so will give the notebook approach a go in that OS. Appreciate your help, much obliged.
Cheers, Simon
@newville, I think this issue can be closed, as wxpython
is now in requirements.txt
, plus the AttributeError is catched in #258.
Hi,
I tried installing Larch using miniconda as well as the bash script on Linux x86-64. In both case I end with an error message related to wx when trying to import larch:
This issue is solved by installing wxpython with conda.
Should wxpython be added as a dependency?