我刚刚安装了Python,开始用Scrapy进行一些实验。 找到第一个安装Miniconda的教程,然后我就可以安装Scrapy了。现在问题是我试图运行的软件也需要Twisted。所以我用pip安装了扭曲。
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'
>>>
有人提出建议吗?
提前致谢,
答案 0 :(得分:2)
要尝试正确安装扭曲,请启动python interpreter并输入
import twisted
如果你无法导入扭曲,你应该检查它是否在你的python路径中。 Python路径可以在python解释器中检查为
import sys
print sys.path
安装twisted的目录必须在这些文件夹中。
答案 1 :(得分:1)
您为python2安装了 twisted 。当您使用命令from multiprocessing import Process, Queue
import time
class Test:
def __init__(self):
print '__init__ is called'
def say_hello_again_and_again(self):
while True:
print 'Hello :D'
time.sleep(1)
test = Test()
process = Process(target=test.say_hello_again_and_again)
process.start()
process.join()
时,您正在为python2安装包。您正在使用python3(3.6.3)。要为python3安装 twisted ,您必须执行以下操作:
pip
我希望这会有所帮助。