Tomáš Derner
Tomáš Derner

Reputation: 31

Pycharm doesn't recognize compiled .pyd even though it works when the script runs

I have a binary module made with pyo3 and rust. It is in a directory with a script that imports it. The directory is marked as source root, so that shouldn't be the problem. There are red squiggly marks under the import, but when I run the script, it runs fine.

directory
  |- string_sum.pyd
  |- test.py

test.py:

import string_sum
print(string_sum.sum_as_string(1, 2))

The output is 3, so it is working. How to make pycharm behave?

Upvotes: 1

Views: 1331

Answers (1)

Ofer Sadan
Ofer Sadan

Reputation: 11942

PyCharm does not support Cython pyd modules out of the box, it can't introspect Cython code so no completion is possible. You can suppress import errors by Alt+Enter | Ignore unresolved reference (on the line marked as error).

Perhaps there's a plug-in for PyCharm to work with these kind of modules, you might want to look into those.

Source: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000648320-Cython-pyd-module-in-PyCharm-CE

Upvotes: 3

Related Questions