简体   繁体   English

Python 导入 - 许多模块无法识别

[英]Python Imports - Many Modules not Recognized

I am trying to follow a tutorial book called "Data visualization with Python and Javascript" and am running into many issues importing modules used in the book.我正在尝试学习一本名为“使用 Python 和 Javascript 进行数据可视化”的教程书,并且在导入书中使用的模块时遇到了许多问题。 I have made sure to do "pip install" on as many of the packages used as possible, and have successfully done it for packages such as SQLAlchemy and matplotlib.我已经确保对尽可能多的使用的包进行“pip install”,并且已经成功地对 SQLAlchemy 和 matplotlib 等包进行了安装。

However, when I import modules from SQLAlchemy and even dateutil that are used in the tutorial, I receive an import error, "ImportError: No module named {module}" On the following lines of code:但是,当我从 SQLAlchemy 甚至是教程中使用的 dateutil 导入模块时,我收到一个导入错误,“ImportError: No module named {module}”在以下代码行中:

from dateutil import parser
from SQLAlchemy import create_engine

This has occurred often enough with different modules that I am beginning to get concerned I can no longer actually follow the tutorial.这在不同的模块中经常发生,我开始担心我不能再真正按照教程进行操作。 I had to skip a whole section of how to use SQLAlchemy.我不得不跳过有关如何使用 SQLAlchemy 的整个部分。 Furthermore, SQLAlchemy is properly installed:此外,SQLAlchemy 已正确安装:

Requirement already up-to-date: sqlalchemy in c:\users\{user}\appdata\local\continuum\miniconda3\lib\site-packages (1.2.15)

What obvious thing am I missing here that needs to happen for me to use these packages and modules?我在这里缺少什么明显的东西,需要我使用这些包和模块?

EDIT:编辑:

python --version
Python 3.7.1
pip --version
pip 18.1 from C:\Users\{user}\AppData\Local\Continuum\miniconda3\lib\site-packages\pip (python 3.7)

However, I am using Anaconda for a virtual environment, and PyCharm as my IDE.但是,我将 Anaconda 用于虚拟环境,并将 PyCharm 作为我的 IDE。 I have included a screenshot of the projects interpreter for a good measure.我已经包含了一个很好的衡量项目解释器的屏幕截图。 Project Interpreter项目口译员

Furthermore, I have checked that I have pip installed it on both the root and the environment.此外,我已经检查过我是否在 root 和环境中都安装了 pip。 Root Environment环境

I think, you have multiple python versions installed.(2.* | 3.*) You are installing packages in one python version and using another python version.我认为,您安装了多个 python 版本。(2.* | 3.*) 您正在一个 python 版本中安装软件包并使用另一个 python 版本。

EDIT: You can use pip2 install modulename for python2 and pip3 install modulename for python3编辑:您可以使用pip2 install modulename for python2 和pip3 install modulename for python3

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

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