question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scrapy: how to rename project

See original GitHub issue

I have created a new project with this command : scrapy startproject first_scrapy

But now i want to change this project name to “web_crawler” . After i tried to change project name , i can not start scrapy command . I got this error :

  File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
  "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\scrapy.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\scrapy\cmdline.py", line 108, in execute
    settings = get_project_settings()
  File "c:\python27\lib\site-packages\scrapy\utils\project.py", line 68, in get_project_settings
    settings.setmodule(settings_module_path, priority='project')
  File "c:\python27\lib\site-packages\scrapy\settings\__init__.py", line 282, in setmodule
    module = import_module(module)
  File "c:\python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  ImportError: No module named first_scrapy.settings

So how can i rename old project ?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
oyeyipocommented, Nov 18, 2017

i had the same problem recently too.

the solution is pretty simple. when you change your file name scrapy setting settings.py has no idea and still refer to the root project module using the previous file name. just change the name to be consistent with your new file name in your settings.py

# -*- coding: utf-8 -*-

# Scrapy settings for tutorial project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     http://doc.scrapy.org/en/latest/topics/settings.html
#     http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
#     http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html

BOT_NAME = 'tutorial'

SPIDER_MODULES = ['tutorial.spiders']
NEWSPIDER_MODULE = 'tutorial.spiders'

# Crawl responsibly by identifying yourself (and your website) on the user-agent
# USER_AGENT = 'tutorial (+http://www.yourdomain.com)'

# Obey robots.txt rules
ROBOTSTXT_OBEY = True

change the old name to the new file name in places where the old filename is being referred to.

hope this helps you.

2reactions
astrungcommented, Jan 12, 2017

i have deleted all .pyc file and still no results

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rename scrapy project - python - Stack Overflow
Basically, you only need to change default = new_project_title under [settings] in scrapy.cfg ...
Read more >
[Example code]-Rename scrapy project - appsloveworld
I want to rename my Scrapy project, spiders made, JSONs created but want to change the name to something meaningful without messing anything...
Read more >
Renaming Projects | PyCharm Documentation - JetBrains
Right-click the root folder of your project and select Refactor | Rename from the context menu or press Shift+F6 . In the dialog...
Read more >
Release notes — Scrapy 1.8.3 documentation
Warn users when project contains duplicate spider names (fixes issue 2181) ... assertItemsEqual was renamed to assertCountEqual in Python 3. (issue 1070).
Read more >
Downloading and processing files and images - Scrapy Docs
To enable your media pipeline you must first add it to your project ITEM_PIPELINES setting. For Images Pipeline, use: ITEM_PIPELINES = {'scrapy.pipelines.images ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found