wiseio / paratext

A library for reading text files over multiple cores.
Apache License 2.0
1.06k stars 103 forks source link

Import fails on OSX 10.12.5 using Anaconda #67

Closed jengelman closed 7 years ago

jengelman commented 7 years ago

I made a virtualenv to test out the package, and importing the module into python failed as follows:


Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import paratext
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "paratext/__init__.py", line 4, in <module>
    from paratext.core import *
  File "paratext/core.py", line 29, in <module>
    import paratext_internal as pti
  File "paratext_internal.py", line 113
    def value(self) -> "PyObject *":
                    ^
SyntaxError: invalid syntax
deads commented 7 years ago

Can you do swig -version and paste the output?

jengelman commented 7 years ago
SWIG Version 3.0.10

Compiled with g++ [x86_64-apple-darwin11.4.2]

Configured options: +pcre
deads commented 7 years ago

The -> arrow notation is Python 3 syntax. The most likely reason for this error is you compiled paratext with Python 3 and imported it with Python 2.

Another thing to note: the stack trace indicates you are pulling from the current directory rather than the prefix where you installed Paratext.

jengelman commented 7 years ago

@deads Tried recompiling with Python2, cd'd to the tests folder, and ran the following

import paratext
df = paratext.load_csv_to_pandas("hepatitis.csv")

and got the following error:


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/joshengelman/miniconda2/envs/paratext/lib/python2.7/site-packages/paratext/core.py", line 403, in load_csv_to_pandas
    return pandas.DataFrame.from_items(expanded)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/frame.py", line 1158, in from_items
    keys, values = lzip(*items)
  File "/Users/joshengelman/miniconda2/envs/paratext/lib/python2.7/site-packages/paratext/core.py", line 355, in load_csv_to_expanded_columns
    for name, col, semantics, levels in load_raw_csv(filename, *args, **kwargs):
  File "/Users/joshengelman/miniconda2/envs/paratext/lib/python2.7/site-packages/paratext/core.py", line 298, in load_raw_csv
    loader = internal_create_csv_loader(filename, *args, **kwargs)
  File "/Users/joshengelman/miniconda2/envs/paratext/lib/python2.7/site-packages/paratext/core.py", line 188, in internal_create_csv_loader
    loader.load(_make_posix_filename(filename), params)
  File "/Users/joshengelman/miniconda2/envs/paratext/lib/python2.7/site-packages/paratext_internal.py", line 530, in load
    return _paratext_internal.ColBasedLoader_load(self, filename, params)
RuntimeError: locale::facet::_S_create_c_locale name not valid
deads commented 7 years ago

Does the solution suggested here work?

jengelman commented 7 years ago

It did not. I checked the language settings, and they look correct:


(paratext) Joshs-MacBook-Pro:tests joshengelman$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"`
deads commented 7 years ago

Does export LC_ALL="C" work for you?

jengelman commented 7 years ago

Yup, thanks!