0

The main.py below runs fine in PyCharm, but if I try to run the main.py in a virtualenv via my terminal, I get the following error:

main.py:

from plotservice import plot_point
from dialog import dialogue

def main():
    """ Main entry point of the app """
    print("hello world")
    d = dialogue()
    d.run_dialog()
    x, y, z = d.get_data()
    plot_point(-x, y, z)


if __name__ == "__main__":
    """ This is executed when run from the command line """
    main()

Error:

➜ python3 main.py
hello world
2019-08-30 21:40:02.712 Python[6862:195147] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7fba7d6d8110
2019-08-30 21:40:02.714 Python[6862:195147] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fba7d6d8110'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff35f332fd __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff60604a17 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff35fad106 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff35ed518f ___forwarding___ + 1485
    4   CoreFoundation                      0x00007fff35ed4b38 _CF_forwarding_prep_0 + 120
    5   libtk8.6.dylib                      0x000000011a3241f2 TkpInit + 408
    6   libtk8.6.dylib                      0x000000011a293aac Initialize + 2454
    7   _tkinter.cpython-37m-darwin.so      0x00000001190ecdc4 Tcl_AppInit + 84
    8   _tkinter.cpython-37m-darwin.so      0x00000001190eca98 _tkinter_create + 1144
    9   Python                              0x000000010c12a4ee _PyMethodDef_RawFastCallKeywords + 430
    10  Python                              0x000000010c129a5a _PyCFunction_FastCallKeywords + 42
    11  Python                              0x000000010c1e85a4 call_function + 724
    12  Python                              0x000000010c1e5576 _PyEval_EvalFrameDefault + 25190
    13  Python                              0x000000010c1e90d6 _PyEval_EvalCodeWithName + 2422
    14  Python                              0x000000010c1295fb _PyFunction_FastCallDict + 523
    15  Python                              0x000000010c12a8cf _PyObject_Call_Prepend + 143
    16  Python                              0x000000010c178d51 slot_tp_init + 145
    17  Python                              0x000000010c1746a9 type_call + 297
    18  Python                              0x000000010c129871 _PyObject_FastCallKeywords + 433
    19  Python                              0x000000010c1e8474 call_function + 420
    20  Python                              0x000000010c1e5576 _PyEval_EvalFrameDefault + 25190
    21  Python                              0x000000010c129e90 function_code_fastcall + 128
    22  Python                              0x000000010c1e85b2 call_function + 738
    23  Python                              0x000000010c1e5617 _PyEval_EvalFrameDefault + 25351
    24  Python                              0x000000010c1e90d6 _PyEval_EvalCodeWithName + 2422
    25  Python                              0x000000010c129a21 _PyFunction_FastCallKeywords + 257
    26  Python                              0x000000010c1e85b2 call_function + 738
    27  Python                              0x000000010c1e555c _PyEval_EvalFrameDefault + 25164
    28  Python                              0x000000010c1e90d6 _PyEval_EvalCodeWithName + 2422
    29  Python                              0x000000010c129a21 _PyFunction_FastCallKeywords + 257
    30  Python                              0x000000010c1e85b2 call_function + 738
    31  Python                              0x000000010c1e555c _PyEval_EvalFrameDefault + 25164
    32  Python                              0x000000010c129e90 function_code_fastcall + 128
    33  Python                              0x000000010c1e85b2 call_function + 738
    34  Python                              0x000000010c1e555c _PyEval_EvalFrameDefault + 25164
    35  Python                              0x000000010c129e90 function_code_fastcall + 128
    36  Python                              0x000000010c1e85b2 call_function + 738
    37  Python                              0x000000010c1e5617 _PyEval_EvalFrameDefault + 25351
    38  Python                              0x000000010c1e90d6 _PyEval_EvalCodeWithName + 2422
    39  Python                              0x000000010c1df234 PyEval_EvalCode + 100
    40  Python                              0x000000010c21c8f1 PyRun_FileExFlags + 209
    41  Python                              0x000000010c21c16a PyRun_SimpleFileExFlags + 890
    42  Python                              0x000000010c23b9db pymain_main + 6875
    43  Python                              0x000000010c23bf2a _Py_UnixMain + 58
    44  libdyld.dylib                       0x00007fff61dd23d5 start + 1
    45  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1]    6862 abort      python3 main.py

After receiving the error code above, python itself crashes...

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895

1 Answers1

0

The problem is probably that you have not installed the packages that you are importing, since "Hello world" does get printed out and the program only crashes afterwards.

PyCharm runs on its own installation of Python, so installing packages in PyCharm does not make them availabe to the "real" Python that is used when executing from the console.

pip install plotservice
pip install dialog

should solve the issue.

Zciurus
  • 786
  • 4
  • 23