1

I had developed an python application to run on Raspbian by using Pycharm. When run in my Raspberry Pi using Pycharm run function, everything is ok, no error.

Then I installed my apps to Raspberry Pi using Pycharm SSH method. The apps able to run also.

However, there is a button that its function is link to config.json file. When I click this button, the apps will close and terminal indicate cannot found config.json file, but this file is already insert into the apps folder when install using Pycharm. FYI, this button able to function as it is when i am running my apps using Run function in Pycharm with Raspberry Pi. Does anyone know how can i solve this?

closed as unclear what you're asking by Milliways, Aurora0001, Seamus, Darth Vader May 3 at 9:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    You will need to provide relevant code for anyone to be able to help you, I would suspect its a relative path issue, if your code just has the path as "config.json" and you run the program from that directory everything is fine, but if you run the program as ./path/to/my/program then the current directory does not contain the needed file. Should always use absolute paths in your code. configFile="/path/to/my/config.json". Or make sure the program changes its working directory correctly. This way no mater where you run the program from, it can find the needed file. – Chad G Apr 18 at 16:48
  • Hi ChadG. thanks. I missed out the path as below. Thanks for your comment with open('/home/pi/temp/AccessDoor/config.json') as json_data_file: – alpha91 Apr 19 at 1:56
  • That's what your path already was? If that's the case and its still not working, update your question showing the path, as most people are probably going to think the same thing. And then post the relevant code so someone might be able to help you. Much better chance of getting a good answer if people dont have to guess at what you have done. – Chad G Apr 19 at 15:09
  • HI, Chad.G, sorry for misleading. that path is what i modified later on and it fix the problem. previously the path just stating only the json file name. – alpha91 Apr 22 at 6:49
  • I edited the answer by @Steve Amor to just reflect the fix. Could you please select it as the correct answer in case others are looking for this type of thing – Chad G Apr 22 at 17:50
1

You need to use the full path of the file, rather than only the file name, this way if the program is run from another location, the path will still be correct.

  • I realize you probably don't have commenting privileges, but this is not an answer, as you stated there is not enough information to provide an answer, but I would suggest removing your post, as it will probably get down voted. – Chad G Apr 18 at 16:45
  • Hi Steve, thanks for your reply. I just realize i missed out the full path of json config file. Thanks for your reminder. Have a nice day. – alpha91 Apr 19 at 1:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.