如何在WSL上安装PyGears-Ubuntu 20.04 LTS [英] How to install PyGears on WSL - Ubuntu 20.04 LTS

查看:204
本文介绍了如何在WSL上安装PyGears-Ubuntu 20.04 LTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有有关如何在WSL上从头开始安装PyGears的说明?我试图在网上找到它,但没有成功.

Is there any instruction on how to install PyGears from scratch on WSL? I tried to find it online but I was unsuccessful.

推荐答案

WSL相当新,与标准Ubuntu完全不同.它通常不带某些软件包,并且总是有丢失某些东西的可能性,因此应该另外添加.

WSL is quite new, and it's quite different than standard Ubuntu. It usually comes without some of the packages and there is always the chance that something is missing and that it should be added additionally.

以下是对我有用的过程:

Here is the process that worked for me:

WSL 2安装

LINK

构建必不可少的

要能够运行所有PyGears工具,我们需要确保已安装所有必需品,请运行以下命令来获取它:

To be able to run all PyGears tools we need to be sure we have all essentials installed, run next commands to get it:

sudo apt update
sudo apt install build-essential

文本编辑器

WSL没有标准的文本编辑器,例如gedit.安装一些您惯用的东西.请记住,对于gedit,您将需要某种服务器才能将gedit显示为GUI应用.

WSL is coming without standard text editor like gedit for example. Install something that you are used to. Have in mind that for gedit you will need some kind of server to be able to show gedit as a GUI app.

WSL 2上的GUI

我还将介绍该主题,以确保您一切正确.为了能够在WSL中查看GUI,您可以安装此工具 VcXsrv .安装后,使用以下设置运行XLaunch:

I will also cover this topic, just to make sure you got everything right. To be able to see GUI in WSL you can install this tool VcXsrv. After installation run XLaunch with these settings:

  • 显示设置:多个窗口,显示编号= -1
  • 客户端启动:不启动客户端
  • 其他设置:选中所有框,然后在其他参数"中保留其他参数"空

我知道这不是超级安全.这样,根据此问题

I know it's not super safe. This allows WSL2 to connect properly though, per this issue and this Github. Note that you'll have to add the export to .bashrc

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 

(或它的某些变体)到您的.bashrc,以便WSL2找到正确的显示.

(or some variant of it), to your .bashrc, so that WSL2 finds the proper display.

如果此解决方案不起作用,请检查

If this solution doesn’t work please check this link.

要测试GUI工作类型

source ~/.bashrc
echo $DISPLAY

应该看到类似这样的内容:172.31.0.1:0

And something like this should be seen: 172.31.0.1:0

安装PyGears

使用pip安装 首先,请确保您已安装pip

Install with pip First, make sure that you have pip installed

sudo apt install python3-pip

PyGears需要Python 3.6或更高版本.使用下面的命令安装PyGears软件包.

PyGears requires Python 3.6 or higher. Install PyGears package with the command below.

sudo pip3 install -U pygears-tools

下一步,键入此命令

pygears-tools-install -d

现在,Qt的xcb插件默认不提供WSL 2,以解决此问题,下一步:

Now, WSL 2 isn’t coming by default with xcb plugin for Qt, to solve this issue type next:

sudo apt-get install --reinstall libxcb-xinerama0

应该的.为了进行测试,您可以使用以下代码:

That should be it. For testing purpose you can use this code:

from pygears import gear
from pygears.typing import Ufixp, Uint
from pygears.lib import drv, collect
from pygears.sim import sim, cosim


@gear
def darken(din, *, gain):
    return din * Ufixp[0, 8](gain)


res = []

drv(t=Uint[8], seq=[12, 23, 255]) \
    | darken(gain=0.5) \
    | float \
    | collect(result=res)

cosim('/darken', 'verilator', outdir='./home/stefan/test/output')
sim()

print(res)

更改outdir以在您的空间中显示某处,并将文件另存为.py并编译为标准python文件.输出应类似于:

Change outdir to show somewhere in your space and save file as .py and compile as standard python file. Output should be something like:

-          /darken/mul [INFO]: Running sim with seed: 2631661647950327284
0                      [INFO]: -------------- Simulation start --------------
103                    [INFO]: ----------- Simulation done ---------------
103                    [INFO]: Elapsed: 0.01
[6.0, 11.5, 127.5]

这篇关于如何在WSL上安装PyGears-Ubuntu 20.04 LTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆