简体   繁体   English

导入错误:没有模块名称 pyautogui

[英]ImportError: No module name pyautogui

In raspberry pi terminal, I am getting在树莓派终端中,我得到

ImportError: No module named pyautogui

but the code runs perfectly fine in Thonny python IDE但是代码在 Thonny python IDE 中运行得非常好

I am trying to schedule a code (code.py) using crontab but the code is not running probably because of ImportError我正在尝试使用 crontab 安排代码 (code.py),但代码没有运行可能是因为 ImportError

import pyautogui

因为你没有pyautogui来安装pyautogui你需要写这个命令:

pip install pyautogui

Hey I got the same error message, and I found that you can solve this in two ways.嘿,我收到了相同的错误消息,我发现您可以通过两种方式解决此问题。 Make sure that you have installed all dependencies properly.确保您已正确安装所有依赖项。 You can try to install these dependencies:您可以尝试安装这些依赖项:

image==1.5.27
numpy==1.17.4
Pillow==6.2.1
requests==2.22.0
opencv-python
olefile==0.46
PyAutoGUI==0.9.48
PyMsgBox==1.0.7
pyobjc-core==6.2
pyobjc-framework-Cocoa==6.1
pyobjc-framework-Quartz==5.3
PyScreeze==0.1.26
PyTweening==1.0.3
pathlib

Add these to your requirements.txt file.将这些添加到您的requirements.txt文件中。

$cd into your project folder and run this installation command pip install -r requirements.txt to install the required binaries. $cd进入您的项目文件夹并运行此安装命令pip install -r requirements.txt以安装所需的二进制文件。 This should solve the problem.这应该可以解决问题。

Please make sure that you are using python version > 3.5 as I found that pyautogui installation is sometimes not compatible with python versions <3.5 so I recommend using version 3.6 .请确保您使用的是python version > 3.5因为我发现pyautogui安装有时与python versions <3.5不兼容,所以我建议使用version 3.6 You can easily create a virtual environment for your project using pyenv and manage multiple version of python versions by switching through them with $pyenv shell <python-version>您可以使用pyenv轻松为您的项目创建virtual environment ,并通过使用$pyenv shell <python-version>切换它们来管理多个版本的python versions

You can try also pip install pywinauto您也可以尝试pip install pywinauto

Both of them are similar.两者都很相似。

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

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