Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyreadstat: No module named 'Cython' #599

Closed
hongseak opened this issue Apr 8, 2022 · 5 comments
Closed

pyreadstat: No module named 'Cython' #599

hongseak opened this issue Apr 8, 2022 · 5 comments
Labels

Comments

@hongseak
Copy link

hongseak commented Apr 8, 2022

#### Java Code
final Python py = Python.getInstance();
pyObject = py.getModule("test222");

#### Python Code
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df_raw = pd.read_spss('/storage/emulated/0/test/data.sav')
print(df_raw.info())

#### pip list
cycler 0.11.0
Cython 0.29.28
fonttools 4.31.2
kiwisolver 1.4.2
matplotlib 3.5.1
numpy 1.22.3
packaging 21.3
pandas 1.4.2
Pillow 9.1.0
pip 22.0.4
pyparsing 3.0.7
pyreadstat 1.1.4
python-dateutil 2.8.2
pytz 2022.1
scipy 1.8.0
setuptools 58.1.0
six 1.16.0
wheel 0.37.1

#### Chaquopy version
< Window Python >
Python 3.10.4

< Android studio >
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "com.chaquo.python:gradle:11.0.0"
}

#### Relevant parts of your build.gradle file

        python {
            buildPython "C:/windows/py.exe", "-3.10"
            pip { // python pip install list
                install "numpy"
                install "scipy"
                install "wheel"
                install "Cython"
                install "matplotlib"
                install "pyreadstat"
                install "setuptools"
                install "pandas"
            }
        }

        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }

When I write the above, the following error occurs.

#### Describe your issue

Collecting Cython
  Using cached https://files.pythonhosted.org/packages/9f/79/311cfbca90332ab37ef8ea08f1af3266f20a9a0e7a1d652842db832226bb/Cython-0.29.28-py2.py3-none-any.whl
Collecting pyreadstat
  Using cached https://files.pythonhosted.org/packages/06/52/ec4b8b826fceaa35767fdb5b883cbbd7848e4413bcb38cbbe7c4069b566f/pyreadstat-1.1.4.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe' -S -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-_kj0worv\\pyreadstat\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-_kj0worv\\pyreadstat\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --no-user-cfg egg_info --egg-base pip-egg-info
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-_kj0worv\pyreadstat\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-_kj0worv\pyreadstat\setup.py", line 21, in <module>
        import Cython
    ModuleNotFoundError: No module named 'Cython'
    ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    ERROR: Command errored out with exit status 1:

    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

ERROR: Failed to install pyreadstat from https://files.pythonhosted.org/packages/06/52/ec4b8b826fceaa35767fdb5b883cbbd7848e4413bcb38cbbe7c4069b566f/pyreadstat-1.1.4.tar.gz.
For assistance, please raise an issue at https://github.com/chaquo/chaquopy/issues.
Chaquopy: Exit status 1
Failed to install pyreadstat from https://files.pythonhosted.org/packages/06/52/ec4b8b826fceaa35767fdb5b883cbbd7848e4413bcb38cbbe7c4069b566f/pyreadstat-1.1.4.tar.gz.

I used "py.read_spss" in python to read the sav file. But an error occurred.
Do you have any solution?

i try input command

  • pip install Cython

Thanks for your help

@mhsmith mhsmith changed the title No module named 'Cython' pyreadstat: No module named 'Cython' Apr 8, 2022
@mhsmith
Copy link
Member

mhsmith commented Apr 8, 2022

Chaquopy runs pip in an isolated environment, so no Python packages you install on the build machine will make any difference.

In this case, the problem is the package pyreadstat, which we haven't yet built for Android. However, it doesn't look as if your code is actually using that package, so maybe you can just remove pyreadstat and Cython from your build.gradle file. We fully support all the other packages you've listed there.

If anyone else wants pyreadstat too, please click the thumbs-up button above.

@hongseak
Copy link
Author

hongseak commented Apr 11, 2022

Thanks for your reply.

"it doesn't look as if your code is actually using that package, so maybe you can just remove pyreadstat and Cython from your build.gradle file."

After modifying the build file, it was built normally, but an error occurs in the log.

Caused by: com.chaquo.python.PyException: ImportError: Missing optional dependency 'pyreadstat'.  Use pip or conda to install pyreadstat.**
        at <python>.pandas.compat._optional.import_optional_dependency(_optional.py:118)
        at <python>.pandas.io.spss.read_spss(spss.py:38)
        at <python>.test222.<module>(test222.py:6) // --> df_raw = pd.read_spss('/storage/emulated/0/test/data.sav')
        at <python>.importlib._bootstrap._call_with_frames_removed(<frozen importlib._bootstrap>:219)
        at <python>.importlib._bootstrap_external.exec_module(<frozen importlib._bootstrap_external>:843)
        at <python>.java.android.importer.exec_module(importer.py:532)
        at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:671)
        at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:975)
        at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:991)
        at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:1014)
        at <python>.importlib.import_module(__init__.py:127)
        at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModuleNative(chaquopy_java.pyx:155)
        at com.chaquo.python.Python.getModuleNative(Native Method)
        at com.chaquo.python.Python.getModule(Python.java:84)
        at com.hssong.pythontest.MainActivity.onCreate(MainActivity.java:44)

Thanks for your help

@mhsmith
Copy link
Member

mhsmith commented Apr 11, 2022

OK, it looks like you do need pyreadstat after all. This isn't a very popular package, so we probably won't provide it in the near future. But if you'd like to try building it yourself, you could license our package build tool. For details, see #175 (comment).

@hongseak
Copy link
Author

hongseak commented Apr 12, 2022

OK.

Thank you so much for providing this feature.

I can't speak English but you sincerely helped me.
You've really made my day!
<( _ _ )>

@mhsmith
Copy link
Member

mhsmith commented Jun 24, 2023

It's been over a year and only one person has requested this package, so we won't be building it in the foreseeable future.

However, the package build tool is now open-source, so if you'd like to try building this package yourself, follow the instructions here. And if you're successful, please make a pull request so we can add it to the public repository.

If anyone else wants this package, please click the thumbs-up button above and post a comment, and I'll reopen the issue.

@mhsmith mhsmith closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants