Home > database >  Making python file running after transferring it from Windows to Ubuntu
Making python file running after transferring it from Windows to Ubuntu

Time:07-31

It's an odd question but I have a problem with running a python file in PyCharm. I developed it on my Windows PyCharm and moved it to my Ubuntu to run it there in PyCharm (I just set it up first time there). I imported the project to Pycharm but can't run the main.py file.

When I try to run the same main.py which goes well on Windows PyCharm I get an error and it seems to be a problem with a path. But I really have no idea where the path is located to change it.

/home/.../env/bin/python: can't open file 'C:\Users...\main.py'

Do I have tp change it in the IDE or is it something that is saved in some file of the project directory?

CodePudding user response:

The problem is that Linux doesn't have partitioning (Drives like C:, D: E: etc.) like Windows.

You will have to locate the file and copy the entire path. Then replace things like C:\Users...\main.py etc. with that new path. You will be able to run the file.

You don't need to change your IDE or anything.

CodePudding user response:

the problem is inside your code there is a path 'C:\Users...\main.py' which only works for the windows operating system. Since you moved your code to ubuntu that path won't work and you have to change that path to the ubuntu environment.

CodePudding user response:

maybe you should run the main.py from right menu in main.py

or you just need replace "\" with "/", it looks like the setting file wrong

  • Related