Hi,
I’m facing an issue while executing my python code. On the Replit interface, I had created a new file because the code was larger and I didn’t want to continue in the previous file. When I executed the code, it instead executed the file of the previous code. I even deleted that file but it just said, " No such file or directory." How may I fix this.
Also, when I write some code, it gives recommendations on what to write, and these are usually the same as what I have to do according to the course. This makes it frustrating as I cannot do it with my understanding, and even if I don’t know how to do something, instead of finding out how to, the software just tells me what to do. I wasn’t able to find out how to remove this in the settings menu. If there is any way, please tell me.
Thank You
Regarding the issue while executing your python code, please make sure that you write your main code in the main.py file that is provided by replit. Do not change the file name of this file. Alternatively you can also share screen shots of your code and error so that we can debug it.
Replit does give code suggestions to improve your efficiency. However if you want to disable it in a repl, go into the User Settings tool and turn off AI code completion . Or, click the AI button near the bottom and disable it from there.
Please do try this and let us know. If you still face any other issues, please feel free to get back to us.
Hi @aryan174401arora ,
Replit, by default will excute the ‘main.py’ file. So, you have import that code into your ‘main.py’ file using the concept of ‘packages’ in python.
The python file other than the main file:
class filename:
def function_name():
#Write you code here and remove the 'pass'. Also Change 'filename' to the name of your python file and change 'function_name' according to your liking.
pass
main.py file:
import filename as f
f.filename.function_name()
Hello,
Thanks for asking this, I am also facing this issue.
Can you please elaborate on the error you are facing? You can also share screenshots of code and the error
Check Execution Settings**: Make sure you have selected the correct file to run in Replit’s interface. Sometimes, the default file for execution might not update automatically after you create a new file.
Clear Cache**: Replit might cache some settings and files. Refresh the page or log out and log back into your Replit account to ensure it reflects the latest changes accurately.
Specify File for Execution**: Explicitly specify the file you want to run. In the Replit console or terminal, navigate to the directory containing your Python script and use the python
command followed by the filename to execute it
Disable Auto-Completion