import a github into jupyter notebook directly?

时光总嘲笑我的痴心妄想 提交于 2020-05-26 09:39:27

问题


Hey Im creating a jupyter notebook, would like to install:

https://github.com/voice32/stock_market_indicators/blob/master/indicators.py which is a python program

not sure how to do it directly so anybody that dowloads the notebook can just hit "Run All", and see the results

option 1) do something like: from https://github.com/voice32/stock_market_indicators/blob/master/indicators.py import indicators.py

of course this doesnt work

Thanks!


回答1:


You can clone the repository from your jupyter notebook using bash. Run in your cell:

%%bash
git clone https://github.com/voice32/stock_market_indicators

This will clone the stock_market_indicators repository to your directory.

You will now be able to access the functions in your indicators.py file. You can import it by running in jupyter:

%load stock_market_indicators/indicators.py



回答2:


I got here searching for the same solution. Here is how I handled it through a Jupyter Terminal. I am using a Chromebook with Amazon SageMaker to host my Jupyter environment.

In the terminal, I used basic git commands (please excuse my mess)

I had a sqlite database file that was 300mb so I added it to my .gitignore file. I then uploaded the 300mb database directly to the same directory as my git clone using the upload function in Jupyter.

I found a cool Chrome Extension, Keep Awake, that allows your computer to sleep but maintain internet if that helps anyone. Now that git has been initiated and my 300mb sqlite database is on my AWS cloud computer I can code on my Chromebook anywhere and push/pull commits.

Hope this helps!



来源:https://stackoverflow.com/questions/52741983/import-a-github-into-jupyter-notebook-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!