python-2.7scrapyscrapinghub

Cant install MySQLdb-python==1.2.5 Scrapinghub (Scrapy) Python 2.7


I read some threads about connecting Mysql with scrapinghub deployed script. They reccomend to change *.yml file and add requirements txt. This solution worked few days ago. Now it doesnt.

enter image description here

Here is error from Shub Deploy.

 Collecting MySQLdb-python==1.2.5 (from -r /app/requirements.txt (line 1))
←[91m  Could not find a version that satisfies the requirement MySQLdb-python==1.2.5 (from -r /app/
requirements.txt (line 1)) (from versions: )
←[0m
←[91mNo matching distribution found for MySQLdb-python==1.2.5 (from -r /app/requirements.txt (line
1))
←[0m
{"message": "The command '/bin/sh -c sudo -u nobody -E PYTHONUSERBASE=$PYTHONUSERBASE     pip insta
ll --user --no-cache-dir -r /app/requirements.txt' returned a non-zero code: 1", "details": {"messa
ge": "The command '/bin/sh -c sudo -u nobody -E PYTHONUSERBASE=$PYTHONUSERBASE     pip install --us
er --no-cache-dir -r /app/requirements.txt' returned a non-zero code: 1", "code": 1}, "error": "req
uirements_error"}
{"status": "error", "message": "Requirements error"}

Is it SH that changed smth or where am I wrong?


Solution

  • 1) You should write MySQL-python==1.2.5 in your requirements.txt file, this is what I have and my project is working fine.

    And then I am using MYSQL like this

    import MySQLdb
    
    conn = MySQLdb.connect(user=DB_CREDS['user'], passwd=DB_CREDS['pass'], db=DB_CREDS['db'], host=DB_CREDS['host'], charset="utf8", use_unicode=True)
    
    cursor = MySQLdb.cursors.DictCursor(conn) 
    
    conn.autocommit(True)
    
    cursor.execute("SELECT myColumn FROM table_name")
    
    for row in self.cursor.fetchall():
        print row['myColumn']
    

    2) Also remove build/ and project.egg-info/ folders before deploying again.

    3) Make sure your scrapinghub.yml file looks like this

    projects:
      default: 123213213
    requirements_file: requirements.txt