标签: windows-subsystem-for-linux

macOS 中 Python 子进程标准输出中出现带有 0xc3 的 UnicodeDecodeError

我正在开发一个 python 脚本来在 WSL 和 macOS 中编译 LaTeX 文件,但当我在 macOS 中运行它时,它在子进程 stdout utf-8 编解码器中失败。但是,它在 WSL 中有效。两个Python版本都是3.6

该代码没有任何代码/解码语句,所以我认为问题出在子进程stdout的内部调用中

def execute(cmd, pipe):
    if pipe:
        ps = subprocess.Popen(cmd, stdout=subprocess.PIPE)
        output = subprocess.check_output(pipe, stdin=ps.stdout, universal_newlines=True)
        print(colored(output, 'red'), file=sys.stderr)
        ps.wait()
    else:
        output = subprocess.call(cmd)
        print(colored(output, 'red'), file=sys.stderr)


start_time = time.time()
for cmd, pipe in zip(commands, pipes):
    print(colored(cmd, 'green'), file=sys.stderr)
    execute(cmd, pipe)
Run Code Online (Sandbox Code Playgroud)

我得到的输出是

['pdflatex', '-shell-escape', '--interaction', 'nonstopmode', '-file-line-error', 'besolidary.tex']
Traceback (most recent call last):
  File "compile.py", line 61, in <module>
    execute(cmd, pipe)
  File "compile.py", line 50, …
Run Code Online (Sandbox Code Playgroud)

macos python-3.x windows-subsystem-for-linux

4
推荐指数
1
解决办法
1559
查看次数

检查在 Linux 的 Windows 子系统中是否在 Vim 中使用 Windows 控制台?

我在 Linux 的 Windows 子系统中使用 Vim。Windows 命令提示符有一个错误,导致背景颜色渲染不正确

解决方法是set t_ut=. 我认为只有在 Windows 控制台内使用 Vim 时才应用它才有意义,而不是在所有情况下都应用此修复。

不幸的是,我不确定如何检测 Windows 控制台是否正在使用,因为我位于 Linux 的 Windows 子系统中。

vim windows-subsystem-for-linux

4
推荐指数
2
解决办法
1333
查看次数

有没有办法从 Windows 主机访问 WSL 文件夹,反之亦然?

我安装了 Windows 2010 home ed,并且最重要的是安装了 Windows 的 Ubuntu 扩展支持。

我已经开始在那里写我的项目,但不知道如何从我的 Windows 系统(主机)访问 Ubuntu 中的目录

有什么想法吗?提前致谢

我宁愿不使用任何外部工具。

windows windows-users windows-subsystem-for-linux

4
推荐指数
1
解决办法
7871
查看次数

WSL 2 真的支持 32 位程序吗?

我用谷歌搜索了这个问题,一些答案声明 WSL 2 现在支持 ELF 32 程序。

然而,在wsl2 Debian/Ubuntu发行版上的简单测试没有通过。

这是我的测试:

// install run-time
sudo dpkg --add-architecture i386
sudo apt-get update
// install build tools
sudo apt install build-essential
sudo apt install gcc-multilib
// build
gcc helloworld.c  -m32
// run!
./a.out
bash: ./a.out: cannot execute binary file: Exec format error
Run Code Online (Sandbox Code Playgroud)

指:

linux x86 32-bit windows-subsystem-for-linux

4
推荐指数
1
解决办法
1万
查看次数

Hugo版本没有更新到最新

我正在尝试使用Hugo 静态站点生成器

问题: Hugo 说它已更新到最新版本,但事实并非如此。

$ hugo version
Hugo Static Site Generator v0.40.1 linux/amd64 BuildDate: 2018-04-25T17:16:11Z

但现在最新版本是v0.70.0

系统: 通过 Visual Studio Code v1.45.0 中的终端进行 Linux 的 Windows 子系统

任何帮助将不胜感激,谢谢大家。

linux hugo visual-studio-code windows-subsystem-for-linux

4
推荐指数
1
解决办法
5122
查看次数

无法选择具有以下功能的设备驱动程序“”:[[gpu]]

我正在尝试在 WSL 2 上安装 Cuda。我正在遵循诸如此类的说明

执行完每个步骤后,我尝试通过执行来检查 gpu 在 Linux 环境中是否可用docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark(如上述说明所建议)。

但我收到以下错误: docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]. ERRO[0000] error waiting for container: context canceled

有什么想法可能是什么原因造成的吗?

ubuntu gpu windows-subsystem-for-linux

4
推荐指数
1
解决办法
1万
查看次数

如何在 WSL 中显示当前分支(我使用 Vscode)

我使用 Vscode,我想知道我的 HEAD 指向哪里分支,
如何像 Bash 一样显示当前分支名称?
我在 Vscode 中使用 WSL(ubuntu)termimal,操作系统是 Windows 10

谢谢

WSL图像

git bash visual-studio-code windows-subsystem-for-linux

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

clang-3.8:在 WSL(适用于 Linux 的 Windows 子系统)中找不到命令

我使用的是WSL(Windows Subsystem for Linux),版本是Ubuntu 20.04 LTS。

BUILD_TOOL = \
    build_tool.o 

CC = clang-3.8

LIBS =  ../out/x64/libmbedcrypto.a

all: build_tool


build_tool: $(BUILD_TOOL)
        $(CC) $(BUILD_TOOL) $(LIBS) -o build_tool
Run Code Online (Sandbox Code Playgroud)

显示错误: clang-3.8: command not found

我尝试通过 apt-get 安装它,但没有安装候选。

$ sudo apt-get install clang-3.8`
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package clang-3.8 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: …
Run Code Online (Sandbox Code Playgroud)

makefile windows-subsystem-for-linux ubuntu-20.04

4
推荐指数
1
解决办法
5411
查看次数

WSL 无法在 VS 代码中运行。这里可能有什么问题?

你好,我是使用 Linux 环境和 VS code 的新手。我使用 Windows 终端访问 WSL2,效果很好。

我正在尝试设置开发环境,但 WSL 无法在 VS code 中工作。我该如何解决这里的问题?它不断显示“VS Code Server for WSL 意外关闭”。信息。

[2020-12-03 07:24:35.010] Resolving wsl+docker-desktop, resolveAttempt: 1
[2020-12-03 07:24:35.106] Starting VS Code Server inside WSL (docker-desktop)
[2020-12-03 07:24:35.106] Extension version: 0.51.4, Windows build: 19041. Multi distro support: available. WSL path support: enabled
[2020-12-03 07:24:35.107] No shell environment set or found for current distro.
[2020-12-03 07:24:35.317] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d docker-desktop -e sh -c "[ -d ~/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f ] …
Run Code Online (Sandbox Code Playgroud)

visual-studio-code windows-subsystem-for-linux

4
推荐指数
2
解决办法
2万
查看次数

在 Windows 10 和 WSL2 之间共享 Git 和 SSH 配置

我在 Windows 10 上安装了 Putty 和 Git,并且还在 Ubuntu 20.04 LTS 中使用 WSL2。有时我想使用 WSL2 中的 SSH 和 Git,其他时候则想在 Windows 中使用。一切工作正常,除了我必须在 Windows 和 WSL2 主目录中复制.gitconfig,.gitignore和文件。.ssh

我不想在两个地方维护这个配置,所以我想我可以在 WSL2 中对文件进行符号链接:

# In /home/myuser on WSL2
ln -s /mnt/c/Users/myuser/.ssh
ln -s /mnt/c/Users/myuser/.gitconfig
ln -s /mnt/c/Users/myuser/.gitignore
Run Code Online (Sandbox Code Playgroud)

除了一些问题之外,这种方法是有效的。

  1. 中的文件/mnt/c具有0777权限,chmod显然不会对它们执行任何操作。当我ssh在 WSL2 中使用时,它抱怨密钥:Permissions 0777 for '/home/myuser/.ssh/id_rsa' are too open
  2. .gitconfig我中core.excludesfile设置为C:\\\\Users\\myuser\\.gitignore,它在 Windows 中使用 Git 时有效,但在 WSL2 中无效。如果我将其更改为/home/myuser/.gitignore它可以在 WSL2 …

git putty windows-10 windows-subsystem-for-linux git-for-windows

4
推荐指数
1
解决办法
2325
查看次数