Code Monkey home page Code Monkey logo

Comments (8)

geirfreysson avatar geirfreysson commented on July 29, 2024

Hi Atanas!

We have people using quantipy3 on Windows on Anaconda, so we should be able to get this to work.

SPSS

I think the SPSS problem might be related to your Anaconda setup. The error seems to be coming from there. People are having similar problems as discussed here, in the conda github (unrelated to Quantipy).

Let me ping on of the folks who has this running on conda so they can share their setup.

ddf/mdd

I think the UNICOM format might be related to the fact that Quantipy is still a bit brittle when it comes to reading values in the data that it expects to be integers but are strings.

For example, if you have a categorical column called gender and it's values in the data are 'male', 'female', 'female' etc. instead of 1,2,1,1 then that might cause an error.

Do you have a datafile that's not client data that you could share with us so we could reproduce the bug and fix it?

from quantipy3.

geirfreysson avatar geirfreysson commented on July 29, 2024

Quantipy is now available via pypi (pip install quantipy3) so this should no longer be an issue.

from quantipy3.

AtanasAtanasov avatar AtanasAtanasov commented on July 29, 2024

Just tried it installing it with pip. It wants me to install some C++ libraries
C:\ProgramData\Anaconda3\envs\qp3\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'define_macros' warnings.warn(msg) running install running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options running build_src build_src building py_modules sources building library "npymath" sources No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ ---------------------------------------- ERROR: Command errored out with exit status 1: 'C:\ProgramData\Anaconda3\envs\qp3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\atana\\AppData\\Local\\Temp\\pip-install-jw1sfgvj\\numpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\atana\\AppData\\Local\\Temp\\pip-install-jw1sfgvj\\numpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\atana\AppData\Local\Temp\pip-record-cci_d97v\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\ProgramData\Anaconda3\envs\qp3\Include\numpy' Check the logs for full command output.

from quantipy3.

geirfreysson avatar geirfreysson commented on July 29, 2024

We need to check this. Thanks for helping out 👍

from quantipy3.

matthoendorf avatar matthoendorf commented on July 29, 2024

I had to make the following changes in savReaderWriter/generic.py in order for this to work on Windows.

Generic class object - load library "msvcrt" instead of searching for c library.

    def __init__(self, savFileName, ioUtf8=False, ioLocale=None):
        """Constructor. Note that interface locale and encoding can only
        be set once"""
        locale.setlocale(locale.LC_ALL, "")
        self.savFileName = savFileName
        if os.name == 'nt':
            self.libc = cdll.LoadLibrary('msvcrt')
        else:
            self.libc = cdll.LoadLibrary(ctypes.util.find_library('c'))
        self.spssio = self.loadLibrary()

        self.wholeCaseIn = self.spssio.spssWholeCaseIn
        self.wholeCaseOut = self.spssio.spssWholeCaseOut

        self.encoding_and_locale_set = False
        if not self.encoding_and_locale_set:
            self.encoding_and_locale_set = True
            self.ioLocale = ioLocale
            self.ioUtf8 = ioUtf8

There was also an issue with the errcheck function for fdopen. In openSavFile(), it sets fdopen.restype to c_void_p. Because of this, when fdopen returns "0", it converts it to None and triggers an error, even though 0 is a valid return value. fdopen.restype should really be a c_int and the errcheck function should trigger an error when the value is -1.

Changes to openSavFile() definition:

fdopen.argtypes, fdopen.restype = [c_int, c_char_p], c_int
fdopen.errcheck = self.errcheck

New errcheck() definition:

    def errcheck(self, res, func, args):
        """This function checks for errors during the execution of
        function <func>"""
        if res == -1:
            msg = "Error performing %r operation on file %r."
            raise IOError(msg % (func.__name__, self.savFileName))
        return res

I haven't tested this change on Linux/Mac.

from quantipy3.

geirfreysson avatar geirfreysson commented on July 29, 2024

@matthewhoendorf can you do a pull request with this and then I can test on Linux and Mac and then we can merge this?

from quantipy3.

matthoendorf avatar matthoendorf commented on July 29, 2024

Will do. There are a few other changes I'm going to include with my PR.

In order to get read_spss working:

  • there's another instance of find_library('c') in headers.py that I fixed
  • in generic.py, locale.getlocale() returns 'en_US.UTF-8' which is a supported value on UNIX, but for Windows, it should be "english", otherwise it will throw an "Invalid ioLocale" error:
    def ioLocale(self, localeName=""):
        if not localeName:
            localeName = ".".join(locale.getlocale())
        if os.name == 'nt' and localeName == 'en_US.UTF-8':
            localeName = 'english'
        func = self.spssio.spssSetLocale
        func.restype = c_char_p
        self.setLocale = func(c_int(locale.LC_ALL), c_char_py3k(localeName))
        if self.setLocale is None:
            raise ValueError("Invalid ioLocale: %r" % localeName)
        return self.setLocale

There might be a better way of doing this to support other languages, but this was my quick hacky fix.

  • (unrelated to SPSS) in dataset.py the meta_to_json function has a syntax error. ''.json([self.name, '_', name, '.json']) should be ''.join([self.name, '_', name, '.json'])

from quantipy3.

geirfreysson avatar geirfreysson commented on July 29, 2024

Closed with pull request #26

from quantipy3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.