Jupyter notebook not reading an existing file - python

I have the exact same file directory but Jupyter Notebook is saying there is no such file or directory found.
Here is the error:
FileNotFoundError: [Errno 2] No such file or directory: 'Macintosh HD/Users/kishanpatel/Documents/Machine Learning Data/train.zip'

When you seek help here it is helpful if you provide more details (e.g. How did you verify that Path) and formulate a question.
I am guessing you are trying to write an absolute path which starts with / on MacOS.
In your case it is maybe /Users/kishanpatel/Documents/Machine Learning Data/train.zip

Related

Can't open Jupyter Notebook files - Unhandled error

I've been having an issue with Jupyter Notebook where I keep getting error
File Load Error for FILENAME.ipynb
Unhandled error
I've looked through many posts including this one that says you can remove the checkpoint folder. I've done that but for some reason it feels like it's ignoring my command
c.FileCheckpoints.checkpoint_dir = ''
The issue seems to be happening with notebooks I've cloned from our Git repo.
When I look at the Jupyter Server output I can see that it's trying to locate the checkpoint file for the file I'm trying to open and it can't find it.
FileNotFoundError: [Errno 2] No such file or directory: '\\\\\\some_folder\\some_folder\\some_folder\\some_folder\\some_folder\\some_folder\\some_folder\\test checkpoints\\some_folder\\.ipynb_checkpoints\\0.Clf_Variable_sig_categorical-checkpoint.ipynb'
I don't understand why it's looking for a checkpoint file? How can I get it to not look for this file and just open the file that I'm trying to open?
This error does not happen to all files that I cloned. Some open others don't, and I can't figure out why it would do that?
Also, if I open the same folder with VS Code, then it opens all the files without any issues.
Any help would be greatly appreciated, I've been going at this for days now and can't figure it out.

JupyterLab - python open() function results in FileNotFoundError

I am trying to open an existing file in a subfolder of the current working directory. This is my command:
fyle = open('/SPAdes/default/{}'.format(file), 'r')
The filevariable contains the correct filename, the folder structure is correct (working on macOS), and the file exists.
This command, however, results if this error message:
FileNotFoundError: [Errno 2] No such file or directory: [filename]
Does it have anything to do with the way JupyterLab works? How am I supposed to specify the folder srtucture on Jupyter? I am able to create a new file in the current folder, but I am not able to create one in a subfolder of the current one (results in the same error message).
The folder structure is recognized on the same Jupyter notebook by bash commands, but I am somehow not able to access subfolders using python code.
Any idea as to what is wrong with the way I specified the folder structure?
Thanks a lot in advance.
There shouldn’t be a forward slash in front of SPAdes.
Paths starting with a slash exist high up in file hierarchy. You said this is a sub-directory of your current working directory.

No such file or directory error when trying to open a file executing a Python script via VSCodium

I've been using VSCodium lately and writing Python code with it. However, I can't seem to find a way to open an existing file when running the script with VSCodium.
This is the code I have, it's working perfectly fine when ran from a terminal, it works. But not with VSCodium.
def remove_e_words(path,path_copy):
newfile = open(path_copy,"w")
orig = open(path,"r")
lines = orig.readlines()
for line in lines:
newfile.write(sans_e_spec(line)+"\n")
newfile.close()
orig.close()
Here's the error I have :
FileNotFoundError: [Errno 2] No such file or directory: 'vers-queneau.txt'
I've searched for similar issues on stackoverflow, I've tried this:
Can't run python code through VS Code. Can't open file ptvsd_launcher.py [Errno 22] Invalid Argument
I have the downgraded version, it still doesn't work.
I also tried to use the file directory instead, changing a parameter in the Settings, it also didn't fix the issue.
What could I do to be able to solve this problem please?
Thanks.
You probably don't have the current working directory set to what you expect. If you run your code with print(os.getcwd()) you will very likely find that is not the directory you expect it to be. Either adjust your relative file path to take that cwd into account or specify the path in an absolute fashion (if the file is next to the file you're running you can calculate its location based on __file__).

Import a .dat file in spyder?

I am supposed to access a .dat file to perform some code. The directions that I am following are telling me to make a subdirectory for the main code then make another subdirectory for the .dat file. However, I am not entirely sure how to do that. Any help would be greatly appreciated!
So far, everything I have tried has given me the following error message:
FileNotFoundError: [Errno 2] No such file or directory

python: can't open file 'lanes.py': [Errno 2] No such file or directory

I am learning OpenCV python and I am watching this YouTube tutorial of "finding lanes for self-driving cars".
At 10:24 of the video, this person opens a command and types python lanes.py.
If I do the same thing,
the command says
"python: can't open file 'lanes.py': [Errno 2] No such file or
directory"
Does anyone know how to fix this? Please do not hesitate to answer.
You don't have a file named lanes.py in the current directory.
Either you never created it, or you created it with the wrong name, or you're in the wrong directory.
Assuming that you have downloaded the tutorial files, make sure that your terminal is in the same directory as the file you want to open.
e.g. If lanes.py is in the folder /Downloads/Python
Then run cd /Downloads/Python to change directory (cd) before you start.
Then you should be able to type your command as:
$: /Downloads/Python> python lanes.py
(or similar, depending on your os)

Categories