0

I want to be able to run python scrapy from the app.py file, without cd .. into the scrape folder to run the application.

This is how my current directory looks like

enter image description here

This is what i have to do to execute the scrapy app

enter image description here

I want to be able to run the app just doing python app.py, and possibly do this without being in virutalenv.

My app.py is blank, cause im unsure how to tell python how to run the app, from the app file.

randal
  • 1,272
  • 3
  • 23
  • 48

1 Answers1

0

Figured it out

App.py

import os
import subprocess 

cw = os.getcwd()
path = '/scrape'
ourPath = cw + os.path.join(path)

if(ourPath):
    os.chdir(ourPath)
    os.system('scrapy crawl yellow')
randal
  • 1,272
  • 3
  • 23
  • 48
  • You are importing `subprocess` but not using it. You should learn how to specify the working directory with `subprocess` and update your response accordingly. – Gallaecio Jan 30 '19 at 09:05