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

Uncaught exception of type NSException for Python 3+ #1

Closed
yingxingcheng opened this issue May 20, 2019 · 5 comments
Closed

Uncaught exception of type NSException for Python 3+ #1

yingxingcheng opened this issue May 20, 2019 · 5 comments

Comments

@yingxingcheng
Copy link

Hi Prof. Verstraelen:

There is an error when I run python tinydft.py in the Mac operating system, shown as follows:

(tinydft) YingxingdeMacBook-Pro:tinydft yxcheng$ python tinydft.py 
Electronic configuration          1s2 2s2 2p6 3s2 3p6 4s2 3d3
Occupation numbers per ang. mom.  [[2.0, 2.0, 2.0, 2.0], [6.0, 6.0], [3.0]]
Nuclear charge                          23
Number of electrons                   23.0
Maximum ang. mol. quantum number         2

Number of radial grid points           512
Number of basis functions               40
Condition number of the overlap    3.0e-11

Pre-computing some integrals ...

Number of SCF iterations                25
Mixing parameter                     0.500

 It        Total      Rad Kin      Ang Kin      Hartree           XC          Ext
=== ============ ============ ============ ============ ============ ============
  0      (guess)
  1  -146.297775  1000.378965  1098.895851   641.130224   -58.824864 -2827.877951
  2  -416.503845   815.664496   789.082941   504.264268   -48.480019 -2477.035532
  3  -505.716805   746.517142   665.655353   430.078499   -43.233462 -2304.734337
  4  -527.025823   727.102634   630.966259   401.225205   -41.337644 -2244.982276
  5  -529.730362   723.928996   626.288455   395.595669   -40.995804 -2234.547679
  6  -529.937654   723.427688   626.116295   394.867815   -40.962420 -2233.387033
  7  -530.087844   723.156703   625.953212   394.481200   -40.945293 -2232.733666
  8  -530.179460   723.027680   625.861019   394.367285   -40.940645 -2232.494799
  9  -530.240590   722.955912   625.788023   394.311675   -40.937903 -2232.358296
 10  -530.272505   722.921117   625.749141   394.291411   -40.936785 -2232.297389
 11  -530.288290   722.904257   625.729162   394.282042   -40.936216 -2232.267534
 12  -530.295408   722.896581   625.720171   394.278368   -40.935977 -2232.254550
 13  -530.298546   722.893085   625.716188   394.276733   -40.935868 -2232.248685
 14  -530.299874   722.891531   625.714528   394.276064   -40.935822 -2232.246174
 15  -530.300430   722.890837   625.713842   394.275769   -40.935802 -2232.245076
 16  -530.300659   722.890529   625.713568   394.275644   -40.935793 -2232.244606
 17  -530.300752   722.890392   625.713459   394.275589   -40.935790 -2232.244402
 18  -530.300790   722.890330   625.713418   394.275565   -40.935788 -2232.244314
 19  -530.300805   722.890302   625.713402   394.275554   -40.935787 -2232.244275
 20  -530.300811   722.890290   625.713396   394.275549   -40.935787 -2232.244258
 21  -530.300814   722.890284   625.713393   394.275547   -40.935787 -2232.244251
 22  -530.300815   722.890281   625.713393   394.275546   -40.935787 -2232.244247
 23  -530.300815   722.890280   625.713392   394.275545   -40.935787 -2232.244246
 24  -530.300816   722.890279   625.713392   394.275545   -40.935787 -2232.244245
2019-05-20 10:05:05.757 python[15602:7317726] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7f91694f86f0
2019-05-20 10:05:05.764 python[15602:7317726] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7f91694f86f0'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff3ad2acf9 __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff658bea17 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff3ada4b06 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00007fff3accd0ef ___forwarding___ + 1485
	4   CoreFoundation                      0x00007fff3accca98 _CF_forwarding_prep_0 + 120
	5   libtk8.6.dylib                      0x000000061d72c31d TkpInit + 413
	6   libtk8.6.dylib                      0x000000061d68417e Initialize + 2622
	7   _tkinter.cpython-37m-darwin.so      0x000000061d4aca0f _tkinter_create + 1183
	8   python                              0x000000010a104116 _PyMethodDef_RawFastCallKeywords + 230
	9   python                              0x000000010a240e42 call_function + 306
	10  python                              0x000000010a23eaec _PyEval_EvalFrameDefault + 46092
	11  python                              0x000000010a23249e _PyEval_EvalCodeWithName + 414
	12  python                              0x000000010a102de7 _PyFunction_FastCallDict + 231
	13  python                              0x000000010a185381 slot_tp_init + 193
	14  python                              0x000000010a18f361 type_call + 241
	15  python                              0x000000010a103ae3 _PyObject_FastCallKeywords + 179
	16  python                              0x000000010a240ed5 call_function + 453
	17  python                              0x000000010a23ebe0 _PyEval_EvalFrameDefault + 46336
	18  python                              0x000000010a1038d5 function_code_fastcall + 117
	19  python                              0x000000010a240dc7 call_function + 183
	20  python                              0x000000010a23eaec _PyEval_EvalFrameDefault + 46092
	21  python                              0x000000010a23249e _PyEval_EvalCodeWithName + 414
	22  python                              0x000000010a102de7 _PyFunction_FastCallDict + 231
	23  python                              0x000000010a106ce2 method_call + 130
	24  python                              0x000000010a104752 PyObject_Call + 130
	25  python                              0x000000010a23ed58 _PyEval_EvalFrameDefault + 46712
	26  python                              0x000000010a23249e _PyEval_EvalCodeWithName + 414
	27  python                              0x000000010a103fe3 _PyFunction_FastCallKeywords + 195
	28  python                              0x000000010a240dc7 call_function + 183
	29  python                              0x000000010a23eb27 _PyEval_EvalFrameDefault + 46151
	30  python                              0x000000010a1038d5 function_code_fastcall + 117
	31  python                              0x000000010a240dc7 call_function + 183
	32  python                              0x000000010a23eb27 _PyEval_EvalFrameDefault + 46151
	33  python                              0x000000010a1038d5 function_code_fastcall + 117
	34  python                              0x000000010a240dc7 call_function + 183
	35  python                              0x000000010a23eaec _PyEval_EvalFrameDefault + 46092
	36  python                              0x000000010a23249e _PyEval_EvalCodeWithName + 414
	37  python                              0x000000010a103fe3 _PyFunction_FastCallKeywords + 195
	38  python                              0x000000010a240dc7 call_function + 183
	39  python                              0x000000010a23eb27 _PyEval_EvalFrameDefault + 46151
	40  python                              0x000000010a23249e _PyEval_EvalCodeWithName + 414
	41  python                              0x000000010a2959a0 PyRun_FileExFlags + 256
	42  python                              0x000000010a294e17 PyRun_SimpleFileExFlags + 391
	43  python                              0x000000010a2c2d3f pymain_main + 9663
	44  python                              0x000000010a0d666d main + 125
	45  libdyld.dylib                       0x00007fff670ec3d5 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

My Python environment is:

# Name                    Version                   Build  Channel
autograd                  1.2                        py_1    conda-forge
blas                      1.0                         mkl    defaults
ca-certificates           2019.1.23                     0    defaults
certifi                   2019.3.9                 py37_0    defaults
cycler                    0.10.0                   py37_0    defaults
freetype                  2.9.1                hb4e5f40_0    defaults
future                    0.17.1                   py37_0    defaults
intel-openmp              2019.3                      199    defaults
kiwisolver                1.1.0            py37h0a44026_0    defaults
libcxx                    4.0.1                hcfea43d_1    defaults
libcxxabi                 4.0.1                hcfea43d_1    defaults
libedit                   3.1.20181209         hb402a30_0    defaults
libffi                    3.2.1                h475c297_4    defaults
libgfortran               3.0.1                h93005f0_2    defaults
libpng                    1.6.37               ha441bb4_0    defaults
matplotlib                3.0.3            py37h54f8f79_0    defaults
mkl                       2019.3                      199    defaults
mkl_fft                   1.0.12           py37h5e564d8_0    defaults
mkl_random                1.0.2            py37h27c97d8_0    defaults
ncurses                   6.1                  h0a44026_1    defaults
numpy                     1.16.3           py37hacdab7b_0    defaults
numpy-base                1.16.3           py37h6575580_0    defaults
openssl                   1.1.1b               h1de35cc_1    defaults
pip                       19.1.1                   py37_0    defaults
pyparsing                 2.4.0                      py_0    defaults
python                    3.7.3                h359304d_0    defaults
python-dateutil           2.8.0                    py37_0    defaults
pytz                      2019.1                     py_0    defaults
readline                  7.0                  h1de35cc_5    defaults
scipy                     1.2.1            py37h1410ff5_0    defaults
setuptools                41.0.1                   py37_0    defaults
six                       1.12.0                   py37_0    defaults
sqlite                    3.28.0               ha441bb4_0    defaults
tk                        8.6.8                ha441bb4_0    defaults
tornado                   6.0.2            py37h1de35cc_0    defaults
wheel                     0.33.4                   py37_0    defaults
xz                        5.2.4                h1de35cc_4    defaults
zlib                      1.2.11               h1de35cc_3    defaults
@yingxingcheng yingxingcheng changed the title Uncaught exception of type NSException Uncaught exception of type NSException for Python 3+ May 20, 2019
@yingxingcheng
Copy link
Author

PS: for ubuntu, there are no these problems.

@yingxingcheng
Copy link
Author

PS: for window, it does work both for Python 2+ and Python 3+ as well.

@tovrstra
Copy link
Member

Thanks for bringing this up. It can be fixed by configuring matplotlib to use the agg backend. Can you try putting the following line in ~/.config/matplotlib/matplotlibrc (can be created if needed):

backend: agg

@yingxingcheng
Copy link
Author

Yes and no, the configuration directory you provided is not suited for my case, but I use the line below to find the configuration directory, and after this, it works! Many thanks.

First, one should obtain the correct matplotlib configuration directory:

>>> import matplotlib as mpl
>>> print(mpl.get_configdir())
>>> '/Users/yxcheng/.matplotlib'

Then, one should create a matplotlibrc file if it doesn't exist and add the line backend : agg:

echo 'backend : agg' >> /Users/yxcheng/.matplotlib/matplotlibrc

Finally, the output of python tinydft.py is:

(tinydft) YingxingdeMacBook-Pro:tinydft yxcheng$ python tinydft.py
Electronic configuration          1s2 2s2 2p6 3s2 3p6 4s2 3d3
Occupation numbers per ang. mom.  [[2.0, 2.0, 2.0, 2.0], [6.0, 6.0], [3.0]]
Nuclear charge                          23
Number of electrons                   23.0
Maximum ang. mol. quantum number         2

Number of radial grid points           512
Number of basis functions               40
Condition number of the overlap    3.0e-11

Pre-computing some integrals ...

Number of SCF iterations                25
Mixing parameter                     0.500

 It        Total      Rad Kin      Ang Kin      Hartree           XC          Ext
=== ============ ============ ============ ============ ============ ============
  0      (guess)
  1  -146.297775  1000.378965  1098.895851   641.130224   -58.824864 -2827.877951
  2  -416.503845   815.664496   789.082941   504.264268   -48.480019 -2477.035532
  3  -505.716805   746.517142   665.655353   430.078499   -43.233462 -2304.734337
  4  -527.025823   727.102634   630.966259   401.225205   -41.337644 -2244.982276
  5  -529.730362   723.928996   626.288455   395.595669   -40.995804 -2234.547679
  6  -529.937654   723.427688   626.116295   394.867815   -40.962420 -2233.387033
  7  -530.087844   723.156703   625.953212   394.481200   -40.945293 -2232.733666
  8  -530.179460   723.027680   625.861019   394.367285   -40.940645 -2232.494799
  9  -530.240590   722.955912   625.788023   394.311675   -40.937903 -2232.358296
 10  -530.272505   722.921117   625.749141   394.291411   -40.936785 -2232.297389
 11  -530.288290   722.904257   625.729162   394.282042   -40.936216 -2232.267534
 12  -530.295408   722.896581   625.720171   394.278368   -40.935977 -2232.254550
 13  -530.298546   722.893085   625.716188   394.276733   -40.935868 -2232.248685
 14  -530.299874   722.891531   625.714528   394.276064   -40.935822 -2232.246174
 15  -530.300430   722.890837   625.713842   394.275769   -40.935802 -2232.245076
 16  -530.300659   722.890529   625.713568   394.275644   -40.935793 -2232.244606
 17  -530.300752   722.890392   625.713459   394.275589   -40.935790 -2232.244402
 18  -530.300790   722.890330   625.713418   394.275565   -40.935788 -2232.244314
 19  -530.300805   722.890302   625.713402   394.275554   -40.935787 -2232.244275
 20  -530.300811   722.890290   625.713396   394.275549   -40.935787 -2232.244258
 21  -530.300814   722.890284   625.713393   394.275547   -40.935787 -2232.244251
 22  -530.300815   722.890281   625.713393   394.275546   -40.935787 -2232.244247
 23  -530.300815   722.890280   625.713392   394.275545   -40.935787 -2232.244246
 24  -530.300816   722.890279   625.713392   394.275545   -40.935787 -2232.244245

@tovrstra
Copy link
Member

This problem is fixed with matplotlib version 3.1.0 (or newer), which are available on pip and (recently) also on conda.

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

2 participants