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

Problem with debugging in Pycharm #821

Open
jirkacigler opened this issue Mar 19, 2024 · 8 comments
Open

Problem with debugging in Pycharm #821

jirkacigler opened this issue Mar 19, 2024 · 8 comments

Comments

@jirkacigler
Copy link

Describe the bug
After upgrading SCIPOptimization suite to 9.0.0 and pyscipopt to 5.0.0., it is not possible to use the same code in debug mode in Pycharm.
Impor of pyscipopt.Model fails with error code

To Reproduce
same error on different win 11 machines

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
from pyscipopt.scip import Model File "complex.pxd", line 19, in init pyscipopt.scip File "src\\pyscipopt\\scip.pyx", line 19, in __Pyx_PyMODINIT_FUNC PyInit_scip(void) TypeError: 'NoneType' object is not callable python-BaseException

System

Additional context
nothing

@Joao-Dionisio
Copy link
Collaborator

Hello, @jirkacigler! Can you please provide the code which is creating the error? Also, what happens if you run the code not using PyCharm, from the command line, for example?

@jirkacigler
Copy link
Author

Debugging crashes on importing of Model
from pyscipopt import Model

For example in pdb, debugging works. But in Pycharm, it fails. This is the complete error output.

`
Connected to pydev debugger (build 223.8836.43)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2022.2.4\plugins\python\helpers\pydev\pydevd.py", line 2195, in
main()
File "C:\Program Files\JetBrains\PyCharm 2022.2.4\plugins\python\helpers\pydev\pydevd.py", line 2177, in main
globals = debugger.run(setup['file'], None, None, is_module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\JetBrains\PyCharm 2022.2.4\plugins\python\helpers\pydev\pydevd.py", line 1489, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\JetBrains\PyCharm 2022.2.4\plugins\python\helpers\pydev\pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Program Files\JetBrains\PyCharm 2022.2.4\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:\dev\tuning_opt.py", line 3, in
from pyscipopt import Model
File "C:\Program Files\Python311\Lib\site-packages\pyscipopt_init_.py", line 23, in
from pyscipopt.scip import Model
File "complex.pxd", line 19, in init pyscipopt.scip
File "src\pyscipopt\scip.pyx", line 19, in __Pyx_PyMODINIT_FUNC PyInit_scip(void)
TypeError: 'NoneType' object is not callable
`

@Opt-Mucca
Copy link
Collaborator

So some minor thoughts:

  • This isn't general to PyCharm (or at least I am not getting errors for PyCharm 2023 on Debian)
  • The error seems to be Cython related. Can you try and run pip install Cython==3.0.9 and then run everything again? (Alternatively if that fails try pip install Cython==0.29)

@NeonDactyl
Copy link

I'm having a similar issue on import of Model, except I'm using VIsual Studio Code on Windows 11 with debugpy to debug.

Running the file directly from python in the terminal, with no debugger attaching, works as expected.

@GasCan666
Copy link

GasCan666 commented Apr 1, 2024

Hello, @jirkacigler! Can you please provide the code which is creating the error? Also, what happens if you run the code not using PyCharm, from the command line, for example?

I have the same problem, just open a py file and write the following one-line code
import pyscipopt as scip
and then use pycharm to Debug that file, error would orrur, same error as jirkacigler's

@banjodd
Copy link

banjodd commented Apr 5, 2024

I'm facing the same issue using the Spyder IDE.

OS: Win 11
Version 5.0.0.
SCIP 8.0.4

When trying to run in debug I get the following error:

File ~\AppData\Local\anaconda3\Lib\site-packages\spyder_kernels\customize\spyderpdb.py:900 in run
super(SpyderPdb, self).run(cmd, globals, locals)

File ~\AppData\Local\anaconda3\Lib\bdb.py:600 in run
exec(cmd, globals, locals)

[...]

model = Model("Test")

File src\pyscipopt\scip.pxi:1004 in pyscipopt.scip.Model.init

TypeError: 'NoneType' object is not callable

@PHonest
Copy link

PHonest commented Apr 19, 2024

I encounter the same error

OS: macOS (ARM)
Version: 5.0.0
SCIP: 9.0.0
Python: 3.12

Furthermore, I used conda to install the relevant dependencies

Reproducible example:

from pyscipopt import Model

model = Model(" modleName ")

This is the produced error:

 File "/home/test/venv/lib/python3.12/site-packages/pyscipopt/__init__.py", line 11, in <module>
    from pyscipopt.scip      import Model
  File "complex.pxd", line 19, in init pyscipopt.scip
TypeError: 'NoneType' object is not callable

Please let me know whether there are further details needed to reproduce the error.

@chuzhixing
Copy link

So some minor thoughts:

  • This isn't general to PyCharm (or at least I am not getting errors for PyCharm 2023 on Debian)
  • The error seems to be Cython related. Can you try and run pip install Cython==3.0.9 and then run everything again? (Alternatively if that fails try pip install Cython==0.29)

here is my environment:
python: 3.8
os: windows
scip: pyscipopt-5.0.0
ide: visual studio code 1.88

my code is

from pyscipopt import Model

I have installed pip install Cython==3.0.9, pip install Cython==0.29.21,both of them not work。

I have tried PySCIPOpt-4.4.0, it has the same question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

8 participants