Pyautogui 未导入“没有名为‘pyautogui’的模块"; [英] Pyautogui not importing "No module named 'pyautogui' "

查看:143
本文介绍了Pyautogui 未导入“没有名为‘pyautogui’的模块";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import pyautogui

print("hello")

运行后,我会看到以下内容:

After running this I am presented with the following:

C:\Users\Darkm\Anaconda3\envs\PythonChallenges\python.exe C:/Users/Darkm/PycharmProjects/PythonChallenges/Automation1.py
Traceback (most recent call last):
  File "C:/Users/Darkm/PycharmProjects/PythonChallenges/Automation1.py", line 1, in <module>
    import pyautogui
ModuleNotFoundError: No module named 'pyautogui'

Process finished with exit code 1

有人能帮我理解为什么我不能导入 pyautogui 吗?

Could somebody help me understand why I cannot import pyautogui?

一些背景信息:

1.) 我只有一个版本的 python (3.7.4)

1.) I only have one version of python (3.7.4)

2.) 我已经在 cmd 提示符下通过pip install pyautogui"安装了模块.

2.) I have already installed the module through "pip install pyautogui" in cmd prompt.

3.) Pyautogui 安装在 C:\Users\Darkm\Anaconda3\Lib\site-packages 下

3.) Pyautogui is installed under C:\Users\Darkm\Anaconda3\Lib\site-packages

4.) 当我进入文件 > 设置 > 项目解释器并尝试添加它时,Pyautogui 没有出现手动(只是不显示).

4.) Pyautogui does not show up when I go into file > settings > project interpreter and try to add it manually (it just doesn't show up).

5.) 多次重启电脑

此时我无法弄清楚为什么我无法导入 pyautogui,任何帮助将不胜感激!

At this point I cannot figure out why I'm unable to import pyautogui, any help would be greatly appreciated!

推荐答案

为什么会出现此错误?

因为您使用的是 PyCharm.

在 PyCharm 中,您不需要从命令提示符安装 python 包,在 PyCharm 中,您需要从 PyCharm Project Interpreter 安装 python 包.

In PyCharm you don't need to install python packages from command prompt, in PyCharm you need to install python packages from PyCharm Project Interpreter.

这里有一些可以帮助您的提示!

Here are some tips that can help you!

第 1 步:转到 PyCharm 设置并转到此目录:首选项并选择解释器设置

Step 1: Go to PyCharm settings and go to this directory: Preferences and select Interpreter Settings

截图:

第 2 步:点击这个加号图标.

Step 2: Click on this plus icon.

截图:

第 3 步:输入您的包名称并选择包.

Step 3: Type your package name and select package.

截图:

第四步:然后点击安装按钮.

Step4: Then click on install button.

第五步:点击确定

然后等待两到三分钟,然后重试.

Then wait for two to three minutes and try again.

希望它会起作用.

这篇关于Pyautogui 未导入“没有名为‘pyautogui’的模块";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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