无法在启动他人项目后使用Scrapy:ModuleNotFoundError

huangapple go评论124阅读模式
英文:

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 &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py&quot;, line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py&quot;, line 86, in _run_code
    exec(code, run_globals)
  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python310\Scripts\scrapy.exe\__main__.py&quot;, line 7, in &lt;module&gt;
  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\cmdline.py&quot;, line 125, in execute
    settings = get_project_settings()
  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\utils\project.py&quot;, line 71, in get_project_settings
    settings.setmodule(settings_module_path, priority=&quot;project&quot;)
  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\scrapy\settings\__init__.py&quot;, line 323, in setmodule
    module = import_module(module)
  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py&quot;, line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1050, in _gcd_import
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1027, in _find_and_load
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 992, in _find_and_load_unlocked
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 241, in _call_with_frames_removed
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1050, in _gcd_import
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1027, in _find_and_load
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named &#39;alien_project&#39;

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&#39;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!

huangapple
  • 本文由 发表于 2023年5月11日 14:16:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76224655.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定