The code in the Linux system suddenly cannot be executed, and there is no permission to access the file, but the file can be viewed in the file manager

foreword

During this period of time, I encountered a very outrageous problem. All my codes that only need to design the data in the mobile hard disk suddenly failed to run. I tossed for a long time and thought that the mobile hard disk was broken, but it can be moved on other computers. Finally stumbled upon the problem today.

Direct conclusion:
the mount point of the mobile hard disk has changed

Detailed description of the problem

For files without access rights, the first instinct is that the file path is wrong, but it seems to be correct. For
example, this code suddenly fails to run.

fin_temp.read_csv("/media/ql/u/Dataset/Template/Left_loop/102_2.csv")

At this time, open the folder manager and find that the name of the mobile hard disk is indeed the u path. It seems that there is nothing wrong with it,
insert image description here
but if you open the terminal here, you will find, send! The actual mount point is actually U1.
I still don’t know the reason for the sudden change of the mount point, but it’s still easy to solve if I know that the mount point has changed.
insert image description here

Solution

Modify the mount point

First use the following command to uninstall the mount (change to your own device)

sudo umount /media/ql/u1

remount

sudo mount /dev/sda1 /media/ql/u

Of course, the "/dev/sda1" here should correspond to your own actual, you can pass

mount | grep '/dev/' 

View the specific device name

After the modification, the mount point will change back

direct method

insert image description here

Change the path in the original code to the path after the mount point changes.
For example, the code just now is modified to

fin_temp.read_csv("/media/ql/u1/Dataset/Template/Left_loop/102_2.csv")

This is helpless, but it seems that after modifying the mount point according to the previous method, the mount point will change back after plugging and unplugging the mobile hard disk.

Guess you like

Origin blog.csdn.net/qin_liang/article/details/131047585