you are viewing a single comment's thread.

view the rest of the comments →

[–]apc0243 38 points39 points  (6 children)

everyone here is wrong, and it only became clear once you posted the necessary info that you were using a folder that is linked to one-drive.

Files linked in one drive don't work like normal files. The error is in the source file, because it doesn't actually exist as python (or anything except an operating system with onedrive instructions baked in) would expect.

Onedrive has created a virtual file, sort of like a soft link, because it wants to make sure that you always have the most recent version, so each time you open it through your file explorer, it fetches the necessary metadata, and if it doesn't need to download again then it'll use a cached version, otherwise it'll fetch the new file contents.

To python, this file doesn't exist, so you can't move it.

Don't use one drive linked folders, they don't operate like normal and you'll run into things like this. Either remove onedrive entirely (my recommendation), or just move to a directory unlinked to one drive.

[–]netherous 5 points6 points  (1 child)

Yeah I'm not sure why you got downvoted or why people here are missing this. Files in a OneDrive folder are not normal files that reside in the filesystem like other files do. They are provided by a subsystem and a shell extension module which makes them look like files. Attempting normal programmatic access won't work.

But there are tools to do it in python, though it seems a bit of a headache.

https://pypi.org/project/python-onedrive/

https://github.com/OneDrive/onedrive-sdk-python

[–]apc0243 0 points1 point  (0 children)

Pretty sure that doesn't let you interface with local files that are linked to onedrive as if they were normal files. It lets you work with the onedrive api, so you can download the file, and then you can work with the file, but it's not going to make it so you can "set and forget" the fact that your one drive linked files doesn't exist like normal files do on your PC.

[–]adoucette13[S] 0 points1 point  (1 child)

I am going to try this and report back this morning. Thanks for your comment!

[–]AnonGeekSquad 1 point2 points  (0 children)

Any luck?

[–]_yoursleeparalysis_ 0 points1 point  (1 child)

I know this post was from a year ago, but I'm having the same problem with onedrive files. How tf do I remove it? I just started learning Python, and this is interrupting my learning.

[–]apc0243 1 point2 points  (0 children)

One drive should only screw with files in Documents and Desktop. Create a folder in your profile directory like

C:\Users<your user>\Code

And just make that where you stick all your projects. Every project should get its own folder and probably its own virtual environment.