简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM