Error when running scrapy

I’m building a flatpak builded project. I have a button, when it is clicked I want it to run a scrapy script to crawl data.

<object class="GtkButton" id="reload_btn">
                            <property name="label" translatable="yes">Reload data</property>
                            <signal name="clicked" handler="on_reload_btn_clicked" swapped="no"/>

import subprocess
    def on_reload_btn_clicked(self,button):
         name = "province"["scrapy",'crawl','province','-O /home/huydq/Projects/CovidTracking/provinces/province.json'],cwd='/home/huydq/Projects/CovidTracking/provinces')

The structure of project is like:

│   └───spiders
│       │
│   └───province.json
    │   window.ui

I tried to make a file to run with the above command, it works fine.
But when I run project it gets following error:

Traceback (most recent call last):
  File "/app/share/covidtracking/covidtracking/", line 88, in on_reload_btn_clicked["scrapy",'crawl','province','-O /home/huydq/Projects/CovidTracking/src/provinces/province.json'],cwd='/home/huydq/Projects/CovidTracking/src/provinces')
  File "/usr/lib/python3.9/", line 349, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.9/", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'scrapy'
Application exited

The last line of the log it saying what’s wrong. It says that it couldn’t find a file called scrapy. Try to give the function the absolute path to the script.

I add shell=True and in runtime I get error: “crawl: line 1: scrapy: command not found”
It appears I don’t import scrapy yet so I add the following in my requirements.txt:
And when I run it get following errors:
Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
Error: module python3-cryptography: Child process exited with code 1

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.