'Pip3: Cython error while installing spicy

This is my requirements.txt file below:

        emoji==1.2.0
        langdetect==1.0.8
        Pillow==9.0.0
        PyMySQL==0.10.1
        pyOpenSSL==19.1.0
        pytz==2020.1
        redis==3.5.3
        regex==2021.8.3
        requests==2.24.0
        selenium==3.141.0
        nltk==3.6.6
        cython==0.29.26
        numpy==1.21.1
        setuptools==59.6.0
        scipy==1.5.4
        geograpy3==0.2.2
        geotext~=0.4.0
        DateTime~=4.3
        uuid~=1.30
        Jinja2~=2.11.2
        boto3==1.17.3

Traceback

    Collecting selenium==3.141.0 (from -r requirements.txt (line 10))
      Using cached https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl
    Collecting nltk==3.6.6 (from -r requirements.txt (line 11))
      Using cached https://files.pythonhosted.org/packages/90/35/8848a41a983a923aa2496fbe4ee4df796c6b32b2a59f04c2b2047aafd3c3/nltk-3.6.6-py3-none-any.whl
    Collecting cython==0.29.26 (from -r requirements.txt (line 12))
      Using cached https://files.pythonhosted.org/packages/15/29/2abb8975ded365d55b9e14129cabdfb977255911c80d8709028eca5829cd/Cython-0.29.26-py2.py3-none-any.whl
    Collecting numpy==1.21.1 (from -r requirements.txt (line 13))
      Using cached https://files.pythonhosted.org/packages/0b/a7/e724c8df240687b5fd62d8c71f1a6709d455c4c09432c7412e3e64f4cbe5/numpy-1.21.1.zip
    Collecting setuptools==59.6.0 (from -r requirements.txt (line 14))
      Using cached https://files.pythonhosted.org/packages/b0/3a/88b210db68e56854d0bcf4b38e165e03be377e13907746f825790f3df5bf/setuptools-59.6.0-py3-none-any.whl
    Collecting scipy==1.5.4 (from -r requirements.txt (line 15))
      Using cached https://files.pythonhosted.org/packages/aa/d5/dd06fe0e274e579e1dff21aa021219c039df40e39709fabe559faed072a5/scipy-1.5.4.tar.gz
        Complete output from command python setup.py egg_info:
        Processing numpy/random/_bounded_integers.pxd.in
        Processing numpy/random/_philox.pyx
        Traceback (most recent call last):
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 53, in process_pyx
            import Cython
        ModuleNotFoundError: No module named 'Cython'
        
        The above exception was the direct cause of the following exception:
        
        Traceback (most recent call last):
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 234, in <module>
            main()
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 230, in main
            find_process_files(root_dir)
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 221, in find_process_files
            process(root_dir, fromfile, tofile, function, hash_db)
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 187, in process
            processor_function(fromfile, tofile)
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 60, in process_pyx
            raise OSError(msg) from e
        OSError: Cython needs to be installed in Python as a module
        Running from numpy source directory.
        Traceback (most recent call last):
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 154, in save_modules
            yield saved
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
            yield
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 250, in run_setup
            _execfile(setup_script, ns)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 45, in _execfile
            exec(code, globals, locals)
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 461, in <module>
            "generating Cython sources and expanding templates".format(
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 443, in setup_package
            bad_commands[command] = "`setup.py %s` is not supported" % command
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 248, in generate_cython
            f.write(text)
        RuntimeError: Running cythonize failed!
        
        During handling of the above exception, another exception occurred:
        
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-build-tqtljvxv/scipy/setup.py", line 583, in <module>
            setup_package()
          File "/tmp/pip-build-tqtljvxv/scipy/setup.py", line 579, in setup_package
            setup(**metadata)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/__init__.py", line 128, in setup
            _install_setup_requires(attrs)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/__init__.py", line 123, in _install_setup_requires
            dist.fetch_build_eggs(dist.setup_requires)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/dist.py", line 510, in fetch_build_eggs
            resolved_dists = pkg_resources.working_set.resolve(
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 772, in resolve
            dist = best[req.key] = env.best_match(
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1057, in best_match
            return self.obtain(req, installer)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1069, in obtain
            return installer(requirement)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/dist.py", line 580, in fetch_build_egg
            return cmd.easy_install(req)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 698, in easy_install
            return self.install_item(spec, dist.location, tmpdir, deps)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 724, in install_item
            dists = self.install_eggs(spec, download, tmpdir)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 909, in install_eggs
            return self.build_and_install(setup_script, setup_base)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 1177, in build_and_install
            self.run_setup(setup_script, setup_base, args)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 1163, in run_setup
            run_setup(setup_script, args)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 253, in run_setup
            raise
          File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
            self.gen.throw(type, value, traceback)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
            yield
          File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
            self.gen.throw(type, value, traceback)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 166, in save_modules
            saved_exc.resume()
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 141, in resume
            six.reraise(type, exc, self._tb)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/_vendor/six.py", line 685, in reraise
            raise value.with_traceback(tb)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 154, in save_modules
            yield saved
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
            yield
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 250, in run_setup
            _execfile(setup_script, ns)
          File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 45, in _execfile
            exec(code, globals, locals)
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 461, in <module>
            "generating Cython sources and expanding templates".format(
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 443, in setup_package
            bad_commands[command] = "`setup.py %s` is not supported" % command
          File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 248, in generate_cython
            f.write(text)
        RuntimeError: Running cythonize failed!
        Cythonizing sources
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-tqtljvxv/scipy/

It looks like related to Cython in spicy package? Does anyone got this error. Thank you guy for helping me.



Solution 1:[1]

I fixed this problem. The reason is my pip3 version was too old (v.9). So I updated it to the newest version, it work like charm.

sudo python3 -m pip install -U pip

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DFX Nguy?n