[英]How to run an IPython CELL magic from a script (%% magic)
Jupyter magic 命令(以單個%開頭,例如%timeit )可以使用How to run an IPython magic from a script (or timing a Python script)中的答案在腳本中運行但是,我找不到關於如何運行單元魔術命令的答案,例如在 Jup ...
[英]How to run an IPython CELL magic from a script (%% magic)
Jupyter magic 命令(以單個%開頭,例如%timeit )可以使用How to run an IPython magic from a script (or timing a Python script)中的答案在腳本中運行但是,我找不到關於如何運行單元魔術命令的答案,例如在 Jup ...
[英]iPython custom cell magic - store output in variable?
我最近發現了 iPython 魔法函數並編寫了一些自定義魔法。 我想使用單元格魔術來解析字符串,稍微更改它們並返回結果。 有沒有辦法將我的自定義單元格魔術 function 的 output 存儲在變量中? 我知道你可以像這樣存儲 line magic function 的 output:@reg ...
[英]Jupyter %%prun magic output not displayed properly in VS Code
最近我遇到了一個問題,%%prun 的輸出在 VS Code Jupyter 中沒有正確顯示(所有輸出都在一行上,而不是在格式良好的表格中)。 我嘗試重新加載窗口並重新啟動 jupyter,但問題仍然存在。 知道可能導致問題的原因嗎? ...
[英]Stop the effect of %matplotlib notebook in Jupyter notebook
我在筆記本的某個 ceil 處使用了魔術命令%matplotlib notebook來為一些散點圖設置動畫。 但是,在那個 ceil 之后,我想刪除這個魔法命令的效果。 任何人都知道如何做到這一點? ...
[英]Why does `IPython.display.Javascript(...)` work to run a Javascript command in a Jupyter cell but not in an IPython magic?
我正在嘗試編寫一個Jupyter nbextension ,用戶可以在其中使用 IPython 魔法配置筆記本范圍的擴展行為。 我計划將配置數據放在 JS 端,在Jupyter.notebook.metadata的應用程序特定鍵下, "tempvars" 。 為了做到這一點,我需要能夠更改.... ...
[英]How to use `client.start_ipython_workers()` in dask-distributed?
我試圖讓工作人員從他們的 ipython kernel 獲取 output 一些信息,並在ipython session 中執行各種命令。 我嘗試了文檔中的示例並且ipyparallel示例有效,但不是第二個示例(使用ipython )。 我無法讓工人執行任何命令。 例如,我被困在以下問題上:fr ...
[英]Define a IPython magic which replaces the content of the next cell
%load line-magic 命令將給定文件的內容加載到當前單元格中,例如,執行: ...將單元格轉換為: 我想創建一個%load_next line-magic 命令,它將這個文件加載到下一個單元格中。 例如,在以下筆記本中執行單元 1: ... 將保持單元格 1 不變並使用新內容更新單 ...
[英]%timeit is working individually but failing with .py file
我正在嘗試將 majic (%timeit) 命令結果捕獲到文本文件,同樣在 ipython 中單獨執行但在 .py 文件中調用,它拋出語法錯誤。 請幫助我我的腳本中到底缺少什么。 錯誤信息:- ...
[英]Programmatically check for and disable IPython autoreload extension
我有一個 function,它使用 Python importlib package 動態重新加載模塊,當用戶從 IPython 運行代碼並加載自動重新加載擴展並打開自動重新加載(即%autoreload 2 autoreload時,會產生一些錯誤。 我想要做的是讓我的代碼檢測用戶是否正在運行 IP ...
[英]IPython shortcut for importing pytest fixtures
假設我正在 IPython 中編寫一個名為test_this_thing的測試,我打算將其逐步保存到測試文件test_some_tests.py中。 在運行我的測試時,我可以從 IPython 輕松地做到這一點,並得到一位同事的這個很好的建議: 假設我在我的測試文件中添加了幾個夾具(用@pytest ...
[英]How to give alias name to commands in jupyter notebook?
我想給 jupyter notebook 中的命令起一個別名,這樣如果我寫: 這個別名將調用我編寫的命令並顯示所需的結果 請幫忙。 ...
[英]Import functions that use ipython magic
在 ipython 單元中,您可以執行 shell 命令,如下所示: 蟒蛇: 但是,如果您嘗試從文件中導入此代碼, asdf.py: 蟒蛇: 它會導致錯誤。 用例是 google colab 中使用 ffmpeg、wget、mount、etc 的重復大量腳本。 雖然您可以使用 os.system ...
[英]Packaging a Python project and its associated IPython magic extension
我正在向 Pypi 部署一個 Python 項目,我們稱之為foobar 。 我想用 shell 命令和IPython 魔術命令分發它。 我使用 Poetry,我的.toml配置文件的相關部分是: 將其上傳到 TestPypi 並使用pip安裝后, shell 命令( foobar )按預期工作。 ...
[英]lost ipython history - database locked
正在玩 ipython 歷史命令,嘗試結合 -l 和 -g 來搜索有限數量的歷史記錄,並使用 -n 來查看命令來自哪個會話。 突然我收到一個錯誤(我希望我的屏幕上仍然有確切的文本)......關於歷史線程遇到的一些錯誤並停止,並且不會保存更多歷史記錄。 它還說了一些關於“數據庫鎖定”的內容。 在那 ...
[英]Can I define magic_arguments for my ipython magic without using the decorator approach?
我已經定義了一個像這樣的自定義 iPython 魔法: 我可以這樣使用它: 現在,我可以在不使用 @magic_arguments 裝飾器的情況下做到這一點嗎? 我想要這個的原因是 - 我必須避免 IPython 模塊的全局導入,因為它們會導致一些其他意想不到的問題。 這意味着我必須將 ' ...
[英]Add reStructuredText support for Juptyer notebooks
我需要在 JupyterLab 中查看 reStructuredText 文件,到目前為止我發現的最好的是@akaihola對 github 上相關問題的回答。 我添加了一個解決方法,允許在不查看源代碼的情況下渲染文件,如下所示。 ...
[英]How to stop an infinite loop safely in JupyterLab?
我們正在使用 jupyterLab 進行一些長時間運行的操作(在我們的案例中進行物理模擬)。 用戶應該能夠在不殺死內核的情況下安全地停止這些操作。 有沒有干凈的方法來做到這一點? 甚至可能有最佳實踐嗎? 我的單元格看起來像這樣: environment = gym.make() runnin ...
[英]Difference between % and %% in ipython magic commands
在 ipython 中使用%timeit和%%timeit有什么區別? 因為當我使用?%timeit和?%%timeit閱讀文檔時,它是相同的文檔。 那么,添加%作為前綴有什么區別呢? ...
[英]ipython-sql: How to connect hive/presto with connect_args?
注意:我將問題發布在https://github.com/catherinedevlin/ipython-sql/issues/149 我可以像這樣使用create_engine連接 hive/presto 但是,如果我使用ipython-sql ,我應該如何連接? 從文檔來看,它似乎只支持傳遞給 ...