How to use link as a pathfile

Hi everyone,

I have a task in jupyter notebook and I want my code and data to be accessed by other users.
So I have uploaded both code and data to a google drive, so I can share it with the others. And now, I want my code to load and read the data from the google drive link (open to everyone that has the link) and not from my local desktop path. But I do not know if this is possible.

I have tried this
pathname = ‘https:/my_drive_path’
url = urllib.request.pathname2url(pathname)
pathname = urllib.url2pathname(url)

but i have the following error
OSError: Bad path: https:/my_drive_path

Is there a simple way of sharing my jupyter notebook and when someone else is running the code, no errors to occur during loading files from the path I have provided?
I currently do not want to use github.

p.s. I am new in programing with python.
Thanks a lot!

Addressing what the title of your post says, the easiest may be just use curl or wget and retrieve the file(s)? See here.

Have you seen here.

Related to getting your code into a cell, have you seen the %load magic command described here. See the section ‘Skipping pasting by loading into a cell’ here for an example use of it.

On the sharing aspect…

MyBinder.org offers other other ways to store your system environment configuration, data, and notebooks as a repository that can be launched besides GitHub. If you go to that link and click the dropdown under ‘GitHub repository name or URL’, you’ll see the list.

I only have examples hosted on GitHub to offer myself. However, the idea is the same wherever hosted. Click here and you’ll get a session that spins up. You can click on notebooks in the list and run them. Everything is installed and ready to go. They are temporary though. They will time out after 10 minutes of inactivity.

requirements.txt here configures what is installed in the environment running in the session that spins up.

As far as not wanting to use GitHub, if you reason is simply to avoid using git to maintain the repository, as long as your needs are simple so that your configuration files are just text (most are), then you can directly use the web interface on GitHub without needing git locally and pushing from your local machine, etc…

See also:


Also when posting code, use backticks to make it possible to paste in code blocks that maintain formatting. See ‘Block code formatting’ here.

2 Likes