简体   繁体   English

无法导入 imagegrab

[英]Can't import imagegrab

Hey I wanted to make a bot for the humenbenchmark aim training ( https://humanbenchmark.com/tests/aim ) but when I try to import imagegrab I get a really long error and I don't know what it means.嘿,我想为 humenbenchmark 目标训练制作一个机器人 ( https://humanbenchmark.com/tests/aim ),但是当我尝试导入 imagegrab 时,我得到了一个很长的错误,我不知道它是什么意思。 The error is:错误是:

  `File "(Path to my python file)", line 1, in <module>
  from PIL import ImageGrab File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 779, in exec_module
  File "<frozen importlib._bootstrap_external>", line 915, in get_code
  File "<frozen importlib._bootstrap_external>", line 973, in get_data
  OSError: [Errno 22] Invalid argument`

And my code is:我的代码是:

from PIL import ImageGrab

Edit: I started testing a little bit and figured out that imagegrab isn't the only module giving that error.编辑:我开始测试了一下,发现 imagegrab 不是唯一出现该错误的模块。 Numpy and pyautogui doesn't work either but modules like random and time does work. Numpy 和 pyautogui 也不起作用,但像随机和时间这样的模块确实起作用。

Answer: If you are on Windows 10, use the CMD (Command prompt) to run the script.答:如果您在 Windows 10,请使用 CMD(命令提示符)运行脚本。

Visual Studio Code sometimes has trouble running it directly through itself. Visual Studio Code 有时无法直接通过自身运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM