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

lmfit fails on python 3.6 #605

Closed
BishopWolf opened this issue Nov 18, 2019 · 7 comments
Closed

lmfit fails on python 3.6 #605

BishopWolf opened this issue Nov 18, 2019 · 7 comments

Comments

@BishopWolf
Copy link

Python 3.6 from Slicer3D package
while importing lmfit

 import lmfit
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/lmfit/__init__.py", line 39, in <module>
    from .confidence import conf_interval, conf_interval2d
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/lmfit/confidence.py", line 10, in <module>
    from .minimizer import MinimizerException
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/lmfit/minimizer.py", line 34, in <module>
    import uncertainties
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/uncertainties/__init__.py", line 224, in <module>
    from .core import *
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/uncertainties/core.py", line 2921
    POSITIVE_DECIMAL_UNSIGNED_OR_NON_FINITE = ur'((\d*)(\.\d*)?|nan|NAN|inf|INF)'
                                              ^
SyntaxError: invalid syntax
@BishopWolf
Copy link
Author

The above is caused by literal python@2 strings not valid for python@3 representation in the uncertainties package, removing ur will fix this issue and expose the next

    import lmfit
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/lmfit/__init__.py", line 39, in <module>
    from .confidence import conf_interval, conf_interval2d
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/lmfit/confidence.py", line 10, in <module>
    from .minimizer import MinimizerException
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/lmfit/minimizer.py", line 34, in <module>
    import uncertainties
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/uncertainties/__init__.py", line 224, in <module>
    from .core import *
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/uncertainties/core.py", line 985, in <module>
    ord(sup): normal for (normal, sup) in TO_SUPERSCRIPT.iteritems()}
AttributeError: 'dict' object has no attribute 'iteritems'

Again this is a python@2 code, changing iteritems() to items() solve the issue and everything works again

@reneeotten
Copy link
Contributor

reneeotten commented Nov 18, 2019

@BishopWolf if you look closely at the Traceback you'll see that both issues are actually in the uncertainties package. Also you don't tell us which version of lmfit and/or uncertainties you have installed); if you don't have the latest versions (0.9.14 for lmfit and 3.1.2 for uncertainties) please try upgrading first. If that still doesn't work please report the problem to the uncertianties developer, I don't think there is anything we can do about this.

@BishopWolf
Copy link
Author

Reported here

BishopWolf added a commit to BishopWolf/uncertainties that referenced this issue Nov 18, 2019
Python2 lines create a conflict making them cause errors in python3.
Refer to [this issue](lmfit/lmfit-py#605) for a complete description
@BishopWolf
Copy link
Author

This pr will solve the issue

@lebigot
Copy link

lebigot commented Nov 18, 2019

The problem is that uncertainties was somehow not properly installed. The setup.py instructs to use the 2to3 in order to transform the original Python 2 code into Python 3 code. This was obviously not done here (Unicode literals get their leading u stripped, iteritems() is replaced by items(), etc.).

So the real solution is to fix the install. Normally python setup.py install does things properly (this is tested through continuous integration), so the way uncertainties was installed inside the Slicer app should be checked.

@lebigot
Copy link

lebigot commented Jun 7, 2020

For reference: version 3.1.4 of uncertainties has universal wheels, which would solve this issue, if a Python 2 version were needed.

@newville
Copy link
Member

newville commented Jun 7, 2020

@lebigot thanks for the update. We dropped support for Python 2 in December. It may be reassuring to people stuck with Python 2 and lmfit 0.9.15 that they will be able to install with pip at least for a little while longer. Then again, no one should expect dependencies to be maintained for Python 2.

I would encourage uncertainties to work toward supporting only Python 3.5+ (r even Python 3.6+, as 3.5 is 3 months from end-of-life).

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

4 participants