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

Problem with pip install on MacOS #33

Open
thiagolcks opened this issue Aug 31, 2017 · 35 comments
Open

Problem with pip install on MacOS #33

thiagolcks opened this issue Aug 31, 2017 · 35 comments

Comments

@thiagolcks
Copy link

I'm using MacOS Sierra and after run brew install hunspell and `pip install hunspell' I'm getting:

Collecting hunspell
  Downloading hunspell-0.5.0.tar.gz
Installing collected packages: hunspell
  Running setup.py install for hunspell ... error
    Complete output from command /Users/thiago/anaconda3/envs/fastAi/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-B4z1YA/hunspell/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-20OFcH-record/install-record.txt --single-version-externally-managed --compile:
    /Users/thiago/anaconda3/envs/fastAi/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'compile_args', 'macros'
      warnings.warn(msg)
    running install
    running build
    running build_ext
    building 'hunspell' extension
    creating build
    creating build/temp.macosx-10.7-x86_64-2.7
    gcc -fno-strict-aliasing -I/Users/thiago/anaconda3/envs/fastAi/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/hunspell -I/Users/thiago/anaconda3/envs/fastAi/include/python2.7 -c hunspell.cpp -o build/temp.macosx-10.7-x86_64-2.7/hunspell.o
    hunspell.cpp:20:10: fatal error: 'hunspell.hxx' file not found
    #include <hunspell.hxx>
             ^
    1 error generated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/Users/thiago/anaconda3/envs/fastAi/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-B4z1YA/hunspell/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-20OFcH-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-B4z1YA/hunspell/

I also run ln -s /usr/local/lib/libhunspell-1.6.a /usr/local/lib/libhunspell.a but it didn't help.

@blatinier
Copy link
Collaborator

Could you try the given solution in that ticket: #26 (the last comment)
It's something I should update in the doc, but I didn't had time yet.

@thiagolcks thiagolcks changed the title Problem with pip install on Python 3 Problem with pip install on Python 2 Aug 31, 2017
@thiagolcks
Copy link
Author

Thanks! It seems to work but when I import it on python cli it shows this message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/thiago/anaconda3/envs/fastAi/lib/python2.7/site-packages/hunspell.so, 2): Symbol not found: __ZN8Hunspell14add_with_affixERKSsS1_
  Referenced from: /Users/thiago/anaconda3/envs/fastAi/lib/python2.7/site-packages/hunspell.so
  Expected in: flat namespace
 in /Users/thiago/anaconda3/envs/fastAi/lib/python2.7/site-packages/hunspell.so

I'm using Python 2.7 not 3.

@blatinier
Copy link
Collaborator

That's a completly new error to me… :(
Apparently you have installed hunspell since installation worked and it does find the .so but it does not find the add_with_affix method…
I don't find similar errors on the internet and I don't own any mac…

Are you stuck to python2 due to an integration to a project or can you move forward to python3? It's the perfect time! :)

I flag the issue with "help-needed" label but I cannot do much more for now.
If you have a way to reproduce this on a linux I'm up to it.

@thiagolcks
Copy link
Author

Same error with Python 3:

Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hunspell
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/thiago/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so, 2): Symbol not found: __ZN8Hunspell14add_with_affixERKSsS1_
  Referenced from: /Users/thiago/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so
  Expected in: flat namespace
 in /Users/thiago/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so

@gbrabelo
Copy link

Hello,

I just managed to install pyhunspell on a clean macOS High Sierra by following these steps:

installed homebrew
installed python (in my case python2) from homebrew (brew install python)

update user path (make sure to be using pip and python from the home brew installation)

brew install hunspell (currently on version 1.6.2, so, adjusting the linking found on comment #26:)

ln -s /usr/local/Cellar/hunspell/1.6.2/lib/libhunspell-1.6.0.dylib /usr/local/Cellar/hunspell/1.6.2/lib/libhunspell.dylib

CFLAGS=$(pkg-config --cflags hunspell) LDFLAGS=$(pkg-config --libs hunspell) pip install hunspell

-> no problem using hunspell

@valerK
Copy link

valerK commented Oct 10, 2017

Hi,

This particular solution didn't work for me on Sierra I needed to modify the setup.py file with the mentioned flags.

I followed the same steps, installed homebrew, python, and hunspell then adjusted the linking with:

ln -s /usr/local/Cellar/hunspell/1.6.2/lib/libhunspell-1.6.0.dylib /usr/local/Cellar/hunspell/1.6.2/lib/libhunspell.dylib

After I cloned this repository I edited this part of the setup.py file like this:

else:
    main_module_kwargs['macros'] = [('_LINUX', None)]
    main_module_kwargs['libraries'] = ['hunspell']
    main_module_kwargs['include_dirs'] = '/usr/local/Cellar/hunspell/1.6.2/include/hunspell/',
    main_module_kwargs['compile_args'] = ['-Wall']
    cmd = ['./configure', '--disable-dependency-tracking', '--without-python', '--with-x=no', 'CFLAGS=$(pkg-config --cflags hunspell)','LDFLAGS=$(pkg-config --libs hunspell)' ]

Running this with
python setup.py install
solved the problem.

@kosta-blank
Copy link

I have the same problem as @thiagolcks - "Expected in: flat namespace". Any solution to that?

@LittleEntertainer
Copy link

I get the same input error as @thiagolcks and @kosta-blank. Is there any other way to resolve this issue?

@MVilstrup
Copy link

I'm experiencing the same problem, thiagolcks, kosta-blank and LittleEntertainer :)

@blatinier
Copy link
Collaborator

Still no mean for me to dig into that. (No Mac near me, and not happening in the near future I'm afraid)
@thiagolcks @kosta-blank @LittleEntertainer @MVilstrup did you tried the solutions provided by @gbrabelo and @valerK ? New errors? Working?

If anyone is finding a way to overcome this issue please comment here.

@bearloga
Copy link

bearloga commented Dec 8, 2017

Hello @blatinier et al.! So I tried solutions by @gbrabelo (partially, because I am using conda python3) and @valerK but to no success :(

Here's the output of a "successful" installation (on macOS High Sierra) via python setup.py install:

running install
running build
running build_ext
building 'hunspell' extension
creating build
creating build/temp.macosx-10.7-x86_64-3.6
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/mpopov/anaconda3/include -arch x86_64 -I/Users/mpopov/anaconda3/include -arch x86_64 -I/usr/local/Cellar/hunspell/1.6.2/include/hunspell/ -I/Users/mpopov/anaconda3/include/python3.6m -c hunspell.cpp -o build/temp.macosx-10.7-x86_64-3.6/hunspell.o
hunspell.cpp:144:30: warning: 'spell' is deprecated [-Wdeprecated-declarations]
    retvalue = self->handle->spell(word);
                             ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:131:3: note: 'spell' has been explicitly marked deprecated here
  H_DEPRECATED int spell(const char* word, int* info = NULL, char** root = NULL);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:164:31: warning: 'suggest' is deprecated [-Wdeprecated-declarations]
    num_slist = self->handle->suggest(&slist, word);
                              ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:141:3: note: 'suggest' has been explicitly marked deprecated here
  H_DEPRECATED int suggest(char*** slst, const char* word);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:175:19: warning: 'free_list' is deprecated [-Wdeprecated-declarations]
    self->handle->free_list(&slist, num_slist);
                  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:155:3: note: 'free_list' has been explicitly marked deprecated here
  H_DEPRECATED void free_list(char*** slst, int n);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:193:31: warning: 'analyze' is deprecated [-Wdeprecated-declarations]
    num_slist = self->handle->analyze(&slist, word);
                              ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:164:3: note: 'analyze' has been explicitly marked deprecated here
  H_DEPRECATED int analyze(char*** slst, const char* word);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:204:19: warning: 'free_list' is deprecated [-Wdeprecated-declarations]
    self->handle->free_list(&slist, num_slist);
                  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:155:3: note: 'free_list' has been explicitly marked deprecated here
  H_DEPRECATED void free_list(char*** slst, int n);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:222:31: warning: 'stem' is deprecated [-Wdeprecated-declarations]
    num_slist = self->handle->stem(&slist, word);
                              ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:168:3: note: 'stem' has been explicitly marked deprecated here
  H_DEPRECATED int stem(char*** slst, const char* word);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:233:19: warning: 'free_list' is deprecated [-Wdeprecated-declarations]
    self->handle->free_list(&slist, num_slist);
                  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:155:3: note: 'free_list' has been explicitly marked deprecated here
  H_DEPRECATED void free_list(char*** slst, int n);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:251:31: warning: 'generate' is deprecated [-Wdeprecated-declarations]
    num_slist = self->handle->generate(&slist, word1, word2);
                              ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:181:3: note: 'generate' has been explicitly marked deprecated here
  H_DEPRECATED int generate(char*** slst, const char* word, const char* word2);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:263:19: warning: 'free_list' is deprecated [-Wdeprecated-declarations]
    self->handle->free_list(&slist, num_slist);
                  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:155:3: note: 'free_list' has been explicitly marked deprecated here
  H_DEPRECATED void free_list(char*** slst, int n);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:282:31: warning: 'generate' is deprecated [-Wdeprecated-declarations]
    num_slist = self->handle->generate(&slist, word1, &desc, 1);
                              ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:191:3: note: 'generate' has been explicitly marked deprecated here
  H_DEPRECATED int generate(char*** slst, const char* word, char** desc, int n);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
hunspell.cpp:294:19: warning: 'free_list' is deprecated [-Wdeprecated-declarations]
    self->handle->free_list(&slist, num_slist);
                  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:155:3: note: 'free_list' has been explicitly marked deprecated here
  H_DEPRECATED void free_list(char*** slst, int n);
  ^
/usr/local/Cellar/hunspell/1.6.2/include/hunspell/hunspell.hxx:89:39: note: expanded from macro 'H_DEPRECATED'
#  define H_DEPRECATED __attribute__((__deprecated__))
                                      ^
11 warnings generated.
creating build/lib.macosx-10.7-x86_64-3.6
g++ -bundle -undefined dynamic_lookup -L/Users/mpopov/anaconda3/lib -arch x86_64 -L/Users/mpopov/anaconda3/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.6/hunspell.o -lhunspell -o build/lib.macosx-10.7-x86_64-3.6/hunspell.cpython-36m-darwin.so
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
running install_lib
copying build/lib.macosx-10.7-x86_64-3.6/hunspell.cpython-36m-darwin.so -> /Users/mpopov/anaconda3/lib/python3.6/site-packages
running install_egg_info
Writing /Users/mpopov/anaconda3/lib/python3.6/site-packages/hunspell-0.5.0-py3.6.egg-info

When I try to import hunspell I get the following:

import hunspell
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/mpopov/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so, 2): Symbol not found: __ZN8Hunspell14add_with_affixERKSsS1_
  Referenced from: /Users/mpopov/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so
  Expected in: flat namespace
 in /Users/mpopov/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so

My hunspell library looks like this:

$ echo $(pkg-config --cflags hunspell)
# -I/usr/local/Cellar/hunspell/1.6.2/include/hunspell
$ ls /usr/local/Cellar/hunspell/1.6.2/include/hunspell
# atypes.hxx	csutil.hxx	htypes.hxx	hunspell.h	hunspell.hxx	hunvisapi.h	w_char.hxx
$ echo $(pkg-config --libs hunspell)
# -L/usr/local/Cellar/hunspell/1.6.2/lib -lhunspell-1.6
$ ls /usr/local/Cellar/hunspell/1.6.2/lib
# libhunspell-1.6.0.dylib	libhunspell-1.6.a	libhunspell-1.6.dylib	libhunspell.a		libhunspell.dylib	pkgconfig

Here's additional information if it could be useful:

$ python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Dec  5 2017, 17:30:25) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

@blatinier blatinier changed the title Problem with pip install on Python 2 Problem with pip install on MacOS Jan 11, 2018
@workflowsguy
Copy link

workflowsguy commented Jan 13, 2018

In the hope this is helpful, here are the commands through which I was able to successfully compile and run pyhunspell on OS X.

Environment:
OS X 10.11.6
Python 3.6.4 (installed via brew)
Hunspell 1.6.2 (installed via brew)

ln -s /usr/local/lib/libhunspell-1.6.2.a /usr/local/lib/libhunspell.a
ln -s /usr/local/Cellar/hunspell/1.6.2/lib/libhunspell-1.6.0.dylib /usr/local/Cellar/hunspell/1.6.2/lib/libhunspell.dylib
CFLAGS=$(pkg-config --cflags hunspell) LDFLAGS=$(pkg-config --libs hunspell) pip3 install hunspell

After successful creation of pyhunspell, run brew prune as suggested by brew doctor

Testing that it works:

Python 3.6.4 (default, Jan  6 2018, 11:49:38) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.

import hunspell
>>> hobj = hunspell.HunSpell('/Users/Guy/Library/Spelling/en_GB.dic', '/Users/Guy/Library/Spelling/en_GB.aff')

>>> print(hobj.spell('Python'))

True

@blatinier
Copy link
Collaborator

Ok anymore positive output for this? @thiagolcks @kosta-blank @LittleEntertainer @MVilstrup @bearloga ?

@bearloga
Copy link

@blatinier Nope :( I tried replicating @workflowsguy's steps but I'm still getting an error when trying to load pyhunspell:

$ brew install hunspell
==> Installing hunspell
==> Downloading https://homebrew.bintray.com/bottles/hunspell-1.6.2.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring hunspell-1.6.2.sierra.bottle.tar.gz
==> Summary
🍺  /usr/local/Cellar/hunspell/1.6.2: 852 files, 1.9MB
$ pip --version
pip 9.0.1 from /Users/mikhail/anaconda3/lib/python3.6/site-packages (python 3.6)
$ CFLAGS=$(pkg-config --cflags hunspell) LDFLAGS=$(pkg-config --libs hunspell) pip install hunspell
Collecting hunspell
  Downloading hunspell-0.5.0.tar.gz
Building wheels for collected packages: hunspell
  Running setup.py bdist_wheel for hunspell ... done
  Stored in directory: /Users/mikhail/Library/Caches/pip/wheels/b3/93/a1/e2b38a49e150a83e070e7abe08d33212fa417ff11d76309f79
Successfully built hunspell
Installing collected packages: hunspell
Successfully installed hunspell-0.5.0
$ python3
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 12:04:33) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hunspell
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/mikhail/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so, 2): Symbol not found: __ZN8Hunspell14add_with_affixERKSsS1_
  Referenced from: /Users/mikhail/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so
  Expected in: flat namespace
 in /Users/mikhail/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so

Environment:

  • macOS 10.12.6 with Xcode 9.2
  • Python 3.6.4 installed via Anaconda

@blatinier
Copy link
Collaborator

Did you create the links suggested (the ln -s commands)? And the post install brew commands?

@bearloga
Copy link

Yup! Sorry, I forgot to include that I created the symbolic links too. I think I ran the post install brew command at some point but I'll try again in the exact order.

@kireet
Copy link

kireet commented Jan 26, 2018

I hit the same issue. I noticed this in the clang command -I/usr/include/hunspell and also that this directory doesn't exist and now /usr/include is on a read only file system. so i cloned this repo and edited install.py to add my hunspell install area to the include dirs:

    main_module_kwargs['include_dirs'] = '/usr/local/Cellar/hunspell/1.6.2/include/hunspell','/usr/local/include'

after this, hunspell seemed to work:

>>> import hunspell
>>> hobj = hunspell.HunSpell('/Library/Spelling/en_US.dic', '/Library/Spelling/en_US.aff')
>>> hobj.suggest('pyton')
['python', 'piton', 'pylon', 'Python']

@blatinier
Copy link
Collaborator

Ok could some of you try to pip install using the issue33/MacOS-install branch?

@kireet
Copy link

kireet commented Jan 30, 2018

works for me. it might be nice to also check some environment variable for the hunspell directory (C_INCLUDE_PATH?) in case someone has a different version (and mention it in the mac install notes.

@blatinier
Copy link
Collaborator

Ok it's merged in the master branch. I will publish on pypi soon.

@jeroarenas
Copy link

jeroarenas commented May 30, 2018

Hi, does any one have any updates on the issue about the error:

Symbol not found: _ZN8Hunspell14add_with_affixERKSsS1

I have tried to get over this error by checking different versions of the hunspell library, installing with pip, and also compiling hte cloned repository myself ... but I was not able to get rid of the error.

@blatinier
Copy link
Collaborator

pypi version was updated regarding this issue at the end of january.
You still encounter this problem?

If yes could you indicate your python version, macos version, hunspell version et full stacktraces?

@jeroarenas
Copy link

jeroarenas commented May 30, 2018

Thanks, I get the problem with the following system:
Mac Os: 10.13.4
Python: 3.6.4 (Anaconda)
Hunspell: I have tried with 1.6.2., 1.3.4, and 1.4.1, currently installed version is 1.4.1

@(#) International Ispell Version 3.2.06 (but really Hunspell 1.4.0)

Compilation from the downloaded code works fine after correcting some links and updating main_module_kwargs['include_dirs'], though it generated some warnings.

Importing hunspell in ipython gives the following error:

ImportError: dlopen(/Users/jarenas/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so, 2): Symbol not found: __ZN8Hunspell14add_with_affixERKSsS1_
Referenced from: /Users/jarenas/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so
Expected in: flat namespace
  in /Users/jarenas/anaconda3/lib/python3.6/site-packages/hunspell.cpython-36m-darwin.so

@blatinier blatinier reopened this May 30, 2018
@blatinier
Copy link
Collaborator

I reopen the subject then, but I still don't own a Mac so troubleshooting this is not possible for me...

@soumyagk
Copy link

soumyagk commented Jun 8, 2018

I have been facing the same error since the past week. And I finally found a hack that worked for me.

My initial system config was:
Mac Os: 10.13.4
Python: 3.6.5 (miniconda)
Hunspell: 1.6.2 (brew)

I tried all suggestions as mentioned in this thread, but they did not work. Clearly the .so file being generated while pip installing hunspell, was buggy. A colleague of mine, who wasn't using miniconda/anaconda, was able to import hunspell without issues following the install instructions mentioned in the above comments.

I decided to inspect the correct and the buggy .so file for clues. So I used otool -l on both individually and compared the outputs.

Buggy file had:

         name @rpath/libstdc++.6.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 7.19.0
compatibility version 7.0.0
Load command 9
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 1252.50.4
compatibility version 1.0.0
Load command 10
          cmd LC_LOAD_DYLIB
      cmdsize 80
         name /Users/sgosukonda/miniconda3/lib/libgcc_s.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 1.0.0
compatibility version 1.0.0

Correct file had:

         name /usr/lib/libc++.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 400.9.0
compatibility version 1.0.0
Load command 10
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 1252.50.4
compatibility version 1.0.0

The difference - correct .so file uses libc++.1.dylib while loading.

I removed miniconda and used brew installed python. That still did not solve the problem.

So finally, I cloned the pyhunspell repo and ran python setup.py develop and that generated the .so file in the path pyhunspell/build/lib.macosx-10.13-x86_64-3.6/hunspell.cpython-36m-darwin.so

This file had the same contents as the correct .so file and I replaced the buggy one with this. import hunspell success. (phew)

Like I mentioned before this is clearly a hack - if anyone can shed more light on how to ensure the .so file generated in a pip install should have libc++.1.dylib as the linked loader - I would much appreciate it.

@zackarydunivin
Copy link

zackarydunivin commented Nov 9, 2018

@soumyagk I see why this solution should work, but I can't build a copy of the .so that references libc++.1.dylib instead of libstdc++.6.dylib. Could you share your file? It happens that my system config is nearly the same as yours.

@soumyagk
Copy link

soumyagk commented Nov 9, 2018

Here's a dropbox link : https://www.dropbox.com/s/7p0tynwdgchhwcj/hunspell.cpython-36m-darwin.so?dl=0

@ursulac
Copy link

ursulac commented May 17, 2019

I followed all the instructions that @valerK provided, but still had an error. Then I tried what @soumyagk recommended and got this error:

creating build/lib.macosx-10.14-intel-2.7
c++ -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.14-intel-2.7/hunspell.o -lhunspell -o build/lib.macosx-10.14-intel-2.7/hunspell.so
ld: library not found for -lhunspell
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'c++' failed with exit status 1

It looks like it can't create the .so file that I need - and neither can I. These are the list of files I have:

libstdc++.6.0.9.dylib
libstdc++.6.dylib
libstdc++.dylib

Can anyone tell me how to manually create the .so file or any other advice? Thank you!

@soumyagk
Copy link

I can't remember now if I ran a different command from python setup.py develop to generate the .so file.
I have been using CyHunspell and it install with no errors: https://github.com/MSeal/cython_hunspell

@usr-ein
Copy link

usr-ein commented Jun 30, 2019

As suggested @workflowsguy I managed to install pyhunspell 0.5.5 from the latest version Hunspell (1.7.0) on Python 3.7.3 by running these commands:

ln -s /usr/local/lib/libhunspell-1.7.a /usr/local/lib/libhunspell.a
ln -s /usr/local/Cellar/hunspell/1.7.0_2/lib/libhunspell-1.7.dylib /usr/local/Cellar/hunspell/1.7.0_2/lib/libhunspell.dylib
CFLAGS=$(pkg-config --cflags hunspell) LDFLAGS=$(pkg-config --libs hunspell) pip3 install hunspell

Hope this helps.

@emorikawa
Copy link

emorikawa commented Oct 1, 2019

@sam1902, these instructions failed with:

...
    In file included from hunspell.cpp:19:
    In file included from /usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:25:
    /Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found
    #include_next <stdio.h>
                  ^~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
...

I should note that all other C extensions compile properly. Xcode tools are updated and everything.

Python 3.7.4 via homebrew
pip3 19.2.3 via homebrew
clean Python 3 virtualenv.
OSX Mojave 10.14.6

It's wild to me that libhunspell.a was pointing to the wrong thing and that libhunspell.dylib didn't exist in my install.

This might be due to Moajve: https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes Has anyone gotten this to work on 10.14?

@emorikawa
Copy link

emorikawa commented Oct 1, 2019

I was able to fix this. I first needed to install XCode 11
I then needed to manually symlink a hardcoded OSX10.14.sdk to the latest SDK via:

ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

I noticed this in my error message:

    Compiling with an SDK that doesn't seem to exist: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
    Please check your Xcode installation
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/hunspell/1.7.0_2/include/hunspell -D_LINUX -I/usr/local/Cellar/hunspell/1.6.2/include/hunspell -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/Users/evanmorikawa/Code/hunspell/env/include -I/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c hunspell.cpp -o build/temp.macosx-10.14-x86_64-3.7/hunspell.o -Wall
    clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]

For some reason, it appeared to be looking for MacOSX10.14.sdk inside of /Applications/Xcode.app. I had previously not installed the full-blown XCode App (just command line tools). After installing Xcode 11, I successfully got the /Applications/Xcode.app folder; however, Xcode 11 installs MacOSX10.15.sdk instead of MacOSX10.14.sdk. As a hack around this, I symlinked the 10.14 SDKs to the 10.15 SDKs, and that appeared to work for the Hunspell compilation

@usr-ein
Copy link

usr-ein commented Oct 2, 2019

@emorikawa this is a macOs 10.14 specific issue with XCode as you mentionned. Symlinking does fix it for me too, but this xcode update breaks many others pip packages too.

@smartworld-dm
Copy link

As suggested @workflowsguy I managed to install pyhunspell 0.5.5 from the latest version Hunspell (1.7.0) on Python 3.7.3 by running these commands:

ln -s /usr/local/lib/libhunspell-1.7.a /usr/local/lib/libhunspell.a
ln -s /usr/local/Cellar/hunspell/1.7.0_2/lib/libhunspell-1.7.dylib /usr/local/Cellar/hunspell/1.7.0_2/lib/libhunspell.dylib
CFLAGS=$(pkg-config --cflags hunspell) LDFLAGS=$(pkg-config --libs hunspell) pip3 install hunspell

Hope this helps.

This worked for me :)
Thanks you

@mglezer
Copy link

mglezer commented Sep 6, 2024

For anyone who is still struggling with this in 2024 on an Apple Silicon (arm) Mac, these are the changes I made to get pyhunspell to build and run:

Preliminary (assume you've done this already)

  1. brew install hunspell
  2. Download dictionaries from http://wordlist.aspell.net/dicts/ and put them in /Library/Spelling/ (you will need sudo for this).

Main

  1. Run (update the versions as needed):
    • ln -s /opt/homebrew/lib/libhunspell-1.7.0.dylib /opt/homebrew/lib/libhunspell.dylib
    • ln -s /opt/homebrew/lib/libhunspell-1.7.a /opt/homebrew/lib/libhunspell.a
  2. Clone this repo. cd into the repo. Ensure you are in the python virtual environment where you want to install pyhunspell.
  3. Modify setup.py:
 elif platform.system() == "Darwin":
     main_module_kwargs['define_macros'] = [('_LINUX', None)]
     main_module_kwargs['libraries'] = ['hunspell']
-    main_module_kwargs['include_dirs'] = '/usr/local/Cellar/hunspell/1.6.2/include/hunspell',
+    main_module_kwargs['library_dirs'] = ['/opt/homebrew/lib']
+    main_module_kwargs['include_dirs'] = ['/opt/homebrew/include/hunspell']
     main_module_kwargs['extra_compile_args'] = ['-Wall']
 else:
...
  1. Run python3 setup.py install.
  2. Open a python shell and enter import hunspell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests