小编ray*_*_lv的帖子

当我尝试在 Julia 中添加 Plots 包时,为什么会收到“检测到包 HTTP 无法满足的要求”错误?

我正在使用 Julia v1.5.2 并使用此代码添加 Plots 包

\n
import Pkg\nPkg.add("Plots")\n
Run Code Online (Sandbox Code Playgroud)\n

我收到下面给出的错误消息。
\n我已尝试重新安装 Julia,并尝试了其他稳定版本 (v1.0),但我仍然收到相同类型的错误消息。我什至尝试使用 Pkg 管理器而不是使用import Pkg,但它似乎也没有什么区别。

\n
ERROR: Unsatisfiable requirements detected for package HTTP [cd3eb016]:\n HTTP [cd3eb016] log:\n \xe2\x94\x9c\xe2\x94\x80HTTP [cd3eb016] has no known versions!\n \xe2\x94\x94\xe2\x94\x80found to have no compatible versions left with Pluto [c3e4b0f8]\n   \xe2\x94\x94\xe2\x94\x80Pluto [c3e4b0f8] log:\n     \xe2\x94\x9c\xe2\x94\x80possible versions are: [0.2.0, 0.3.0-0.3.6, 0.4.0-0.4.3, 0.5.0-0.5.21, 0.6.0-0.6.4, 0.7.0-0.7.10, 0.8.0-0.8.10, 0.9.0-0.9.11, 0.10.0-0.10.13, 0.11.0-0.11.14, 0.12.0-0.12.3] or uninstalled\n     \xe2\x94\x94\xe2\x94\x80restricted to versions * by an explicit requirement, leaving only versions [0.2.0, 0.3.0-0.3.6, 0.4.0-0.4.3, …
Run Code Online (Sandbox Code Playgroud)

julia plots.jl

6
推荐指数
1
解决办法
2731
查看次数

有没有更快的方法使用 pyglet 和线程在屏幕上绘图?

下面的三个函数展示了我如何使用 pyglet 库在屏幕上绘制正方形。该代码运行良好。但我想让它跑得更快。

根据我对线程的新手理解,我认为使用线程可以使 for 循环draw_grid()更快,因为它等待一个正方形被绘制pos,然后绘制一个新的正方形。既然all_positions已经提供了,有没有办法同时绘制所有正方形?

def draw_square(single_location):
    # draws a single square
    pyglet.graphics.draw_indexed(4, pyglet.graphics.gl.GL_TRIANGLES,
                             [0,1,2,1,2,3],
                             ('v2i', single_location))

def position_array():
    # returns an 2D array with each row representing the coordinates of the rectangle to draw
    ...relevant code...
    return all_positions

def draw_grid(all_positions):
    # uses draw_square function and all_positions to draw multiple squares at the specified locations.
    for pos in all_positions:
        draw_square(pos)
Run Code Online (Sandbox Code Playgroud)

在查找了一些有关线程的视频后,我找到了该concurrent.futures库。所以我尝试实现它,但它给了我错误。所以现在我被困住了。

这是我concurrent.futures.ThreadPoolExecutor()在里面使用的方法draw_grid()

def draw_grid(all_positions):
    # uses draw_square function …
Run Code Online (Sandbox Code Playgroud)

python multithreading pyglet concurrent.futures

2
推荐指数
1
解决办法
537
查看次数