使用适用于 Windows 的 Linux 子系统 (LSW),clip.exe可用于将数据复制到 Windows 剪贴板:
$ clip.exe /?
CLIP
Description:
Redirects output of command line tools to the Windows clipboard.
This text output can then be pasted into other programs.
Parameter List:
/? Displays this help message.
Examples:
DIR | CLIP Places a copy of the current directory
listing into the Windows clipboard.
CLIP < README.TXT Places a copy of the text from readme.txt
on to the Windows clipboard.
Run Code Online (Sandbox Code Playgroud)
有没有办法从剪贴板管道?预期用途示例:
$ paste.exe > …Run Code Online (Sandbox Code Playgroud) 我无法从 WSL2 子系统访问我的家庭网络。我在里面安装了 Ubuntu。
anirban@Desktop:/mnt/g/BASH_WORKSPACE$ lsb_release -a No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
anirban@Desktop:/mnt/g/BASH_WORKSPACE$ uname -r 4.19.57-microsoft-standard
Run Code Online (Sandbox Code Playgroud)
WSL2 中的 eth0 具有以下配置:
anirban@Desktop:/mnt/g/BASH_WORKSPACE$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.20.213.230 netmask 255.255.240.0 broadcast 172.20.223.255
inet6 fe80::215:5dff:fecf:39a5 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:cf:39:a5 txqueuelen 1000 (Ethernet)
RX packets 100 bytes 10544 (10.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 936 (936.0 B)
TX errors 0 …Run Code Online (Sandbox Code Playgroud) 当我尝试从 WSL 执行代码时,如下所示:
cmd.exe
wsl code .
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
/bin/bash: code: command not found
Run Code Online (Sandbox Code Playgroud)
但是,如果我执行相同的命令但首先以管理员身份运行 cmd.exe,vscode 会按预期打开。
问题是为什么当我以非管理员身份运行时无法识别“代码”,我该如何解决?
附加信息:WSL2 版本 41959 vscode 版本 1.38 vscode 远程 WSL 扩展版本 0.39.5
visual-studio-code windows-subsystem-for-linux vscode-remote
Intellij IDEA 安装在 Windows 上。使用 maven 构建的 java 应用程序需要本机库(使用 JNI)并在 Ubuntu 上运行。
在 Windows 上使用 maven 和 git 很好。如何让 Intellij IDEA 使用 WSL 中的 JDK,以便我可以创建使用 WSL 的运行/调试配置?
java debugging intellij-idea windows-subsystem-for-linux wsl-2
我在 Hyper-V 上创建了一个带有 2 个网络适配器的 VM。
从我的命令行,我能够使用 Nat Switch IP 连接到 VM,但是从 WSL Bash 我无法连接 IP NatSwitch,但能够连接 ExternalSwitch IP。
为什么?
我一直在将 vscode 设置为 python 开发的 IDE。我使用适用于 Linux 的 Windows 子系统,并通过 anaconda 安装了我的 python 软件包。
我的问题是自动完成功能无法按预期工作。例如,在 wsl 之外,如果我使用 numpy 包,我可以获得自动补全:
但是,在 wsl 自动完成内部找不到 numpy.linalg (如上面的示例所示):
提前致谢!
编辑:如果该信息相关,我目前正在使用 wsl1!
在 WSL2(当前文件夹)中运行/home/my-linux-user/:
az aks get-credentials --resource-group my-resource-group --name cluster-name
输出:
Merged "cluster-name" as current context in C:\Users\my-windows-user\.kube\config
我需要做什么才能让 Azure CLI 将 kube 配置放入 WSL 中的 Linux 主文件夹中?
azure-cli windows-subsystem-for-linux azure-aks windows-terminal
我正在尝试使用以下方式验证 gcloud sdk gcloud init:。
我得到了一个应该访问的 URL,以便复制令牌并将其返回到 CLI...但我得到的不是令牌,而是以下错误:
Erreur d'autorisation
Erreur 400 : invalid_request
Missing required parameter: redirect_uri
Run Code Online (Sandbox Code Playgroud)
这是一个错误吗?
gcloud version信息:
Google Cloud SDK 377.0.0
alpha 2022.03.10
beta 2022.03.10
bq 2.0.74
bundled-python3-unix 3.8.11
core 2022.03.10
gsutil 5.8
Run Code Online (Sandbox Code Playgroud)
gcloud init我在 wsl2 (Ubuntu 18.04) 上运行。安装 gcloud 后立即出现此错误sudo apt install google-cloud-sdk。
oauth-2.0 google-cloud-platform gcloud windows-subsystem-for-linux wsl-2
我正在尝试使用特定的python 版本创建一个新的虚拟环境。
当我输入:
python3 -m virtualenv --python="D:\Python_Versions\python.exe" new_virtualenv
Run Code Online (Sandbox Code Playgroud)
我得到:
RuntimeError:无法找到内置发现 python_spec='D:\Python_Versions\python.exe' 的解释器
打开 Windows 命令提示符
wsl --install
Run Code Online (Sandbox Code Playgroud)
来源: https: //learn.microsoft.com/en-us/windows/wsl/install
打开 Windows 命令提示符:
bash
Run Code Online (Sandbox Code Playgroud)
然后
sudo apt-get install python-pip
Run Code Online (Sandbox Code Playgroud)
类型
pip install virtualenv
Run Code Online (Sandbox Code Playgroud)
前往: https: //www.python.org/downloads/release/python-360/
下载:Windows x86-64 可执行安装程序
安装到您选择的文件夹中,即D:\Python_Versions\
在命令提示符中,转到项目文件夹(“cd ...”)并键入:
python3 -m virtualenv --python="D:\Python_Versions\python.exe" new_virtualenv
Run Code Online (Sandbox Code Playgroud)
在 Windows 上的当前目录中,我有以下脚本文件 simple_script.sh:
#!/bin/bash
echo "hi from simple script"
Run Code Online (Sandbox Code Playgroud)
我希望通过 powershell 命令行在 wsl 上运行此脚本。
使用该wsl命令,我找不到告诉 wsl 调用脚本代码的方法。
以下命令有效(我认为)
wsl bash -c "echo hi from simple script"
Run Code Online (Sandbox Code Playgroud)
但是,当尝试将脚本内容加载到变量中并运行时,它无法按预期工作:
$simple_script = Get-Content ./simple_script.sh
wsl bash -c $simple_script
Run Code Online (Sandbox Code Playgroud)
失败:
bash: -c: option requires an argument
Run Code Online (Sandbox Code Playgroud)
我尝试了几种变体。Get-Content与标志一起使用-Raw似乎会打印字符串中的第一个单词(但不是整个字符串)。不包含“”字符的命令有时似乎有效。但我还没有找到一致的方法。
类似的问题似乎不能直接与 wsl 一起工作,并且似乎不能运行驻留在 Windows 文件系统上的脚本文件。
windows-subsystem-for-linux ×10
wsl-2 ×3
azure-aks ×1
azure-cli ×1
bash ×1
clipboard ×1
debugging ×1
gcloud ×1
java ×1
networking ×1
oauth-2.0 ×1
powershell ×1
python ×1
virtualenv ×1
windows-10 ×1