Jetson.GPIO "Could not determine Jetson Model" only in PyCharm, works otherwise

I am trying to use the Jetson.GPIO library on a Jetson Orin Nano Super Developer Kit running Jetpack 6.2.1.

To illustrate my question, there is this simple program, let’s call it jetson_info.py.

import Jetson.GPIO as GPIO  

print(GPIO.JETSON_INFO) 

When running it from CLI

python jetson_info.py

I get the following output

{'P1_REVISION': 1, 'RAM':'32768M, 65536M', 'REVISION': 'Unknown', 'TYPE': 'JETSON_ORIN_NANO', 'MANUFACTURER': 'NVIDIA', 'PROCESSOR': 'A78AE'}

Running it in an virtual environment gives the same result.

Now, when trying to run it in PyCharm, using the same virtual environment, I get the following error at import.

Exception: Could not determine Jetson model

Does anybody know what causes these different behavior?

Thank you very much.

*** Please note that this reply is generated by LLM automatically ***

The issue you’re experiencing is likely due to the way PyCharm handles the Python interpreter and the environment variables. When you run your script from the command line interface (CLI), it uses the system’s Python interpreter and the environment variables set in your shell. However, when you run it in PyCharm, it uses the Python interpreter and environment variables configured in the PyCharm project settings.

Here are a few possible reasons for the different behavior:

  1. Python interpreter: PyCharm might be using a different Python interpreter than the one you’re using in the CLI. Make sure that the Python interpreter configured in PyCharm is the same as the one you’re using in the CLI. You can check this in PyCharm by going to Settings > Project: [your project name] > Project Interpreter.
  2. Environment variables: PyCharm might not be inheriting the environment variables set in your shell. You can try setting the environment variables manually in PyCharm by going to Settings > Project: [your project name] > Project Interpreter > Environment Variables.
  3. Working directory: PyCharm might be using a different working directory than the one you’re using in the CLI. Make sure that the working directory in PyCharm is set to the same directory where your script is located. You can set the working directory in PyCharm by going to Settings > Project: [your project name] > Project Interpreter > Working Directory.

To troubleshoot the issue, you can try the following:

  1. Check the Python interpreter and environment variables in PyCharm and make sure they match the ones you’re using in the CLI.
  2. Try running your script in PyCharm using the python command instead of the jetsoninfopy command. This will help you determine if the issue is specific to the jetsoninfopy command or if it’s a general issue with running Python scripts in PyCharm.
  3. Try setting the PYTHONPATH environment variable in PyCharm to include the directory where the JetsonGPIO library is installed.

If none of these solutions work, please provide more details about your PyCharm configuration and the error message you’re seeing, and I’ll do my best to help you troubleshoot the issue.

Comparison with other Jetson devices

The issue you’re experiencing is specific to the Jetson Orin Nano Super Developer Kit and PyCharm. However, it’s worth noting that the JetsonGPIO library is designed to work with all Jetson devices, including the Jetson Orin NX and Jetson AGX Orin.

If you’re experiencing similar issues with other Jetson devices, you can try the same troubleshooting steps I mentioned earlier. However, if you’re using a different Jetson device, you may need to consult the specific documentation for that device to ensure that you’re using the correct Python interpreter and environment variables.

Additional resources

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

Hi loris.christen,

Could you check if the Update gpio_pin_data.py for Jetson Orin Nano Super (#119) · NVIDIA/jetson-gpio@1eaefd8 · GitHub could help for your case?

I added “JETSON_MODEL_NAME=JETSON_ORIN_NANO” in the environment variables of the Run configuration. It seems to me as a dirty fix but it works.

1 Like