英文:
Can't use Scrapy after launching someone's project: ModuleNotFoundError
问题
I was working on scrapy and received project (let's name it "alien_project") from other developer, after launching it I've faced scrapy problems. My old projects works and completes but when I try to create new projects error appears, seems like it tries to start from that "alien_project". Here's error I get in terminal:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\Scripts\scrapy.exe\__main__.py", line 7, in <module>
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\cmdline.py", line 125, in execute
settings = get_project_settings()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\utils\project.py", line 71, in get_project_settings
settings.setmodule(settings_module_path, priority="project")
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\settings\__init__.py", line 323, in setmodule
module = import_module(module)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'alien_project'
I already tried to reinstall Python. I also get this error working in virtual environment. Didn't find something suspicious in that project, maybe it's just a coincidence, but Scrapy always refers to that "alien_project" project.
I'm using: Windows 11 | Scrapy 2.9.0. | Python 3.10.9
英文:
I was working on scrapy and received project (let's name it "alien_project") from other developer, after launching it I've faced scrapy problems. My old projects works and completes but when I try to create new projects error appears, seems like it tries to start from that "alien_project". Here's error I get in terminal:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\Scripts\scrapy.exe\__main__.py", line 7, in <module>
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\cmdline.py", line 125, in execute
settings = get_project_settings()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\utils\project.py", line 71, in get_project_settings
settings.setmodule(settings_module_path, priority="project")
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\settings\__init__.py", line 323, in setmodule
module = import_module(module)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'alien_project'
I already tried to reinstall Python. I also get this error working in virtual environmet. Didn't find somethins suspicious in that project, maybe it's just an coincedence, but Scrapy always refers to that "alien_project" project.
I'm using: Windows 11 | Scrapy 2.9.0. | Python 3.10.9
答案1
得分: 0
我找到了问题并解决了。不知何故,在我的项目文件夹的顶层有一个名为'alien_project'的scrapy.cfg的副本。我猜测Scrapy试图引用该scrapy配置文件。我只是将其删除,现在一切都正常。
感谢所有试图帮助我的人!
英文:
I found the problem and solved it. Somehow there's was copy of scrapy.cfg of 'alien_project' above all my project folder. I guess Scrapy tried to refer to that scrapy config file. I just removed it and know everything works.
Thanks for all people trying to help me!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论