tillahoffmann / obsidian-jupyter

MIT License
437 stars 23 forks source link

Can't get result #42

Closed qiaogaojian closed 2 years ago

qiaogaojian commented 2 years ago

After click run button, it always keeps running and don't returns result, here is the log:

created new client for doc 512e4640c73a8626 using interpreter C:\Program Files\Python\python.exe
VM156:3115 INFO:obsidian-jupyter:started server for document 512e4640c73a8626

VM156:3115 INFO:obsidian-jupyter:received request: {"id":"88551b87-a5c0-4f9b-92dd-57ea2eccc942","body":{"command":"execute","source":"\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sympy import *\n\nx = np.linspace(0,500000,10000)\ny = 500000- 500 - x\nplt.plot(x,y,color='blue')\n \ny = x * 3 - 500 - x\nplt.plot(x,y,color='red')\n\nplt.xlim(0,500000)\nplt.ylim(0,500000)  \n\nplt.show()  \n\n# 解方程\nx = Symbol(\"x\")\ny = Symbol(\"y\")\nres = solve([500000- 500 - x - y, x * 3 - 500 - x - y],[x, y])\n\nprint( \"A: {:.2f} B: {:.2f}\".format(float(res[y]),float(res[x])))\n"}}

VM156:3115 C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\zmq\_future.py:679: RuntimeWarning: Proactor event loop does not implement add_reader family of methods required for zmq. Registering an additional selector thread for add_reader support via tornado. Use `asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())` to avoid this warning.
  self._get_loop()

VM156:3115 INFO:traitlets:Executing notebook with kernel: 

the log stop at "VM156:3115 INFO:traitlets:Executing notebook with kernel" .

here is my code:

import numpy as np
import matplotlib.pyplot as plt
from sympy import *

x = np.linspace(0,500000,10000)
y = 500000- 500 - x
plt.plot(x,y,color='blue')

y = x * 3 - 500 - x
plt.plot(x,y,color='red')

plt.xlim(0,500000)
plt.ylim(0,500000)  

plt.show()  

x = Symbol("x")
y = Symbol("y")
res = solve([500000- 500 - x - y, x * 3 - 500 - x - y],[x, y])

print( "A: {:.2f} B: {:.2f}".format(float(res[y]),float(res[x])))

btw, running simple code like print("hello world") can get result but costs a long time (about 10 seconds).

my os is win10, obsidian verison is 0.14.6

Device name DESKTOP-H7SP6IQ
Processor   AMD Ryzen 5 PRO 4400G with Radeon Graphics        3.70 GHz
Installed RAM   32.0 GB (31.4 GB usable)
Device ID   0944A73F-489C-4167-89EC-C6B9B85D2344
Product ID  00330-80000-00000-AA891
System type 64-bit operating system, x64-based processor
Pen and touch   No pen or touch input is available for this display

Edition Windows 10 Pro
Version 21H2
Installed on    ‎12/‎4/‎2021
OS build    19044.1706
Experience  Windows Feature Experience Pack 120.2212.4170.0
tillahoffmann commented 2 years ago

Does this work as expected when you run the script from the normal python interpreter?

qiaogaojian commented 2 years ago

Does this work as expected when you run the script from the normal python interpreter?

I didn't try normal python interpreter, but it works as expected in vscode with jupyter plugin.

qiaogaojian commented 2 years ago

I found that it works sometimes.