简体   繁体   English

没有名为“ Twisted”的模块

[英]No module named 'Twisted'

I just installed Python to start experimenting a bit with Scrapy. 我刚刚安装了Python,开始尝试使用Scrapy。 Found a tutorial to first install Miniconda and with this I was able to install Scrapy. 找到了一个首先安装Miniconda的教程,并由此可以安装Scrapy。 Now the problem is that the software I'm trying to run also requires Twisted. 现在的问题是,我尝试运行的软件也需要Twisted。 So I installed twisted with pip. 所以我安装了点子扭。

Twisted seems to have been installed correctly but I'm still getting an error when running the script that the Twisted module could not be found. Twisted似乎已正确安装,但是在运行找不到Twisted模块的脚本时仍然出现错误。

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 
================ RESTART: C:\xampp\htdocs\crawler\crawler.py ================
Traceback (most recent call last):
  File "C:\xampp\htdocs\crawler\crawler.py", line 3, in <module>
    from scrapy.utils.project import get_project_settings
  File "C:\xampp\htdocs\crawler\scrapy\__init__.py", line 43, in <module>
    from twisted import version as _txv
ModuleNotFoundError: No module named 'twisted'
>>> 
================ RESTART: C:\xampp\htdocs\crawler\crawler.py ================
Traceback (most recent call last):
  File "C:\xampp\htdocs\crawler\crawler.py", line 3, in <module>
    from scrapy.utils.project import get_project_settings
  File "C:\xampp\htdocs\crawler\scrapy\__init__.py", line 43, in <module>
    from twisted import version as _txv
ModuleNotFoundError: No module named 'twisted'
>>> 

Anybody a suggestion? 有人建议吗?

Thanks in advance, 提前致谢,

To try if twisted correctly installed, start python interpreter and type 要尝试正确安装扭曲,请启动python解释器并输入

import twisted

If you can't import twisted, you should check if it is in your python path. 如果无法导入twisted,则应检查它是否在python路径中。 Python path can be checked in the python interpreter as 可以在python解释器中检查Python路径为

import sys
print sys.path

The directory, where your twisted is installed has to be among those folders. 安装绞线的目录必须在这些文件夹中。

You installed twisted for python2. 您安装了适用于python2的twisted When you use the command pip , you are installing a package for python2. 当使用命令pip ,您正在安装python2的软件包。 You are using python3 (3.6.3). 您正在使用python3(3.6.3)。 To install twisted for python3, you have to do: 要为python3安装twisted ,必须执行以下操作:

pip3 install twisted

I hope this helps. 我希望这有帮助。

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

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