小能豆

How do I use installed packages in PyCharm?

py

In PyCharm, I’ve added the Python environment /usr/bin/python. However,

from gnuradio import gr

fails as an undefined reference. However, it works fine in the Python interpreter from the command line.

GNURadio works fine with python outside of Pycharm. Everything is installed and configured how I want it.

Gnuradio is located at /usr/local/lib/python2.7/site-packages/gnuradio

Also:

PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages/gnuradio


阅读 77

收藏
2023-12-23

共1个答案

小能豆

The issue you are facing seems to be related to the Python interpreter configured in PyCharm not being able to find the GNURadio libraries. Here are some steps you can try to resolve this issue:

  1. Configure PyCharm Interpreter:
  2. Open PyCharm and go to “File” -> “Settings” -> “Project: ” -> “Python Interpreter.”
  3. Make sure that the interpreter you have selected points to the correct Python executable (in your case, /usr/bin/python).
  4. Check PYTHONPATH in PyCharm:
  5. In the same “Python Interpreter” settings, check the “Environment variables” section.
  6. Make sure that the PYTHONPATH environment variable includes the paths to GNURadio libraries. You can add the paths manually if they are not there.
  7. Rebuild PyCharm Project:
  8. Sometimes, PyCharm’s caches may become outdated. Try rebuilding the project by going to “File” -> “Invalidate Caches / Restart” -> “Invalidate and Restart.”
  9. Check PyCharm Run Configuration:
  10. If you are running a script or application, make sure that the run configuration in PyCharm is using the correct Python interpreter and has the necessary environment variables set.
  11. Check System Paths:
  12. Ensure that the GNURadio paths are included in the system’s LD_LIBRARY_PATH. You can export this variable in your shell profile or add it directly to PyCharm’s run configurations.

If the issue persists, you may need to dig deeper into the GNURadio installation and PyCharm’s interpreter configuration to ensure they are compatible. Additionally, you can try running PyCharm from the terminal where GNURadio works to see if there are any specific error messages related to library loading.

Remember that GNURadio might have dependencies and runtime requirements that are needed for correct operation. Ensure that all required libraries and paths are correctly set up for both the system and PyCharm.

2023-12-23