Home > database >  Python File Not Found whilst both python and excel file in the same folder. Why?
Python File Not Found whilst both python and excel file in the same folder. Why?

Time:10-31

I watched the youtube from enter image description here

The full path to the folder is /Users/User/M/M1/DS project

I have tried these filenames, Test, Test.xlsx, Test.xlsx.xlsx but doesn't seem to help.

I believe it should be a simple fix but I just can't find the solution after reading so many relevant posts. Can someone help please? Thanking in advance.

CodePudding user response:

Please try and use the full file path and see if the issue persists. In my experience VS code runs the python script in a different location than where it is saved. So it might be looking for the file in a different directory than where it is saved.

CodePudding user response:

You must use the python virtualenv model for your projects. This provides an environment for the program to understand the connection of your files.

  1. Create a directory and put your files in it.
  2. Open terminal and install virtualenv :

pip install virtualenv

  1. In terminal, Get in the project directory and create new venv:

python -m virtualenv venv

  1. Now you have to active you venv:

source venv/bin/activate

now start runnig your project.

for deactivate directory just type:

deactivate

  • Related