我在EC2实例上.所以没有GUI.
$pip install selenium
$sudo apt-get install firefox xvfb
Run Code Online (Sandbox Code Playgroud)
然后我这样做:
$Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null &
$DISPLAY=:1 java -jar selenium-server-standalone-2.0b3.jar
05:08:31.227 INFO - Java: Sun Microsystems Inc. 19.0-b09
05:08:31.229 INFO - OS: Linux 2.6.32-305-ec2 i386
05:08:31.233 INFO - v2.0 [b3], with Core v2.0 [b3]
05:08:32.121 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
05:08:32.122 INFO - Version Jetty/5.1.x
05:08:32.123 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
05:08:32.124 INFO - Started HttpContext[/selenium-server,/selenium-server]
05:08:32.124 INFO - Started HttpContext[/,/]
05:08:32.291 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@1186fab …Run Code Online (Sandbox Code Playgroud) 环境:Python 2.7,matplotlib 1.3,IPython笔记本1.1,linux,chrome.代码在一个输入单元格中,使用--pylab=inline
我想使用IPython笔记本和pandas来消耗流并每5秒动态更新一次.
当我只使用print语句以文本格式打印数据时,它完全正常:输出单元格只保留打印数据并添加新行.但是当我尝试绘制数据(然后在循环中更新它)时,绘图永远不会出现在输出单元格中.但如果我删除循环,只需绘制一次.它工作正常.
然后我做了一些简单的测试:
i = pd.date_range('2013-1-1',periods=100,freq='s')
while True:
plot(pd.Series(data=np.random.randn(100), index=i))
#pd.Series(data=np.random.randn(100), index=i).plot() also tried this one
time.sleep(5)
Run Code Online (Sandbox Code Playgroud)
在手动中断进程(ctrl + m + i)之前,输出不会显示任何内容.在我打断它之后,该图正确显示为多个重叠的行.但我真正想要的是一个每5秒显示并更新一次的情节(或者每当plot()函数被调用时,就像我上面提到的print语句输出一样,效果很好).仅在单元格完成后才显示最终图表不是我想要的.
我甚至尝试在每个之后显式添加draw()函数plot()等.它们都不起作用.想知道如何通过IPython笔记本中一个单元格内的for/while循环动态更新绘图.
我有Ubuntu 11.04我正在尝试安装Xvfb和CutyCapt以获取网页的快照我按照指令 https://github.com/jaequery/cutycapt-installer-script-on-ubuntu/blob/master/install 和我执行了最后一行,它给了我一个错误
xvfb-run:错误:Xvfb无法启动
任何解决方案?先感谢您
我想在笔记本中玩OpenAI体育馆,并且将体育馆内联渲染。
这是一个基本示例:
import matplotlib.pyplot as plt
import gym
from IPython import display
%matplotlib inline
env = gym.make('CartPole-v0')
env.reset()
for i in range(25):
plt.imshow(env.render(mode='rgb_array'))
display.display(plt.gcf())
display.clear_output(wait=True)
env.step(env.action_space.sample()) # take a random action
env.close()
Run Code Online (Sandbox Code Playgroud)
这行得通,我在笔记本中看到了健身房:
但!它还会打开一个交互式窗口,显示完全相同的内容。我不希望打开此窗口:
python reinforcement-learning python-3.x jupyter-notebook openai-gym
我正试图在Jupyter笔记本中显示AI-Gym演示.我获得了Atari演示的良好结果Breakout-v0以及购物车极点演示的难度错误消息CartPole-v0.两者在笔记本电脑外都很好用.以下是最小的细节:
在控制台:
$ pip install gym[atari] &> /dev/null
$ /anaconda3/bin/python3
Python 3.6.3 |Anaconda, Inc.| (default, Oct 6 2017, 12:04:38)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gym
>>> env = gym.make('Breakout-v0')
>>> env.reset()
>>> env.render()
Run Code Online (Sandbox Code Playgroud)
结果:
现在,同样使用cart-pole,在一个新的Python会话中:
$ pip install gym &> /dev/null
$ /anaconda3/bin/python3
Python 3.6.3 |Anaconda, Inc.| (default, Oct 6 2017, 12:04:38)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type …Run Code Online (Sandbox Code Playgroud) 我试图在无头服务器中运行健身房,并在jupyter中进行渲染。Python版本2.7。
我已经开始使用jupyter xvfb-run -a -s "-screen 0 1400x900x24" jupyter notebook
下面是我运行的Jupyte单元。
import matplotlib.pyplot as plt
import gym
from IPython import display
%matplotlib inline
env = gym.make('CartPole-v0')
env.reset()
plt.imshow(env.render(mode='rgb_array'))
display.display(plt.gcf())
display.clear_output(wait=True)
env.step(env.action_space.sample()) # take a random action
env.close()
Run Code Online (Sandbox Code Playgroud)
但是我得到的错误如下:
AttributeError: 'ImageData' object has no attribute 'data'
Run Code Online (Sandbox Code Playgroud)
我在论坛上进行了大量搜索,但找不到解决方案。在此先感谢您帮助我解决此错误,并让我在jupyter笔记本中渲染体育馆。
python ×4
openai-gym ×3
linux ×2
matplotlib ×2
ipython ×1
jupyter ×1
pandas ×1
python-2.7 ×1
python-3.x ×1
selenium ×1
ubuntu ×1
unix ×1