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

import bcrypt error #64

Closed
carrchr opened this issue May 6, 2016 · 6 comments
Closed

import bcrypt error #64

carrchr opened this issue May 6, 2016 · 6 comments

Comments

@carrchr
Copy link

carrchr commented May 6, 2016

>>> import bcrypt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../venv/lib/python2.7/site-packages/bcrypt/__init__.py", line 23, in <module>
    from bcrypt import _bcrypt
ImportError: dlopen(.../venv/lib/python2.7/site-packages/_cffi_backend.so, 2): Symbol not found: _PyUnicodeUCS2_AsASCIIString
  Referenced from: .../venv/lib/python2.7/site-packages/_cffi_backend.so
  Expected in: flat namespace
 in ...venv/lib/python2.7/site-packages/_cffi_backend.so

This might be an issue with cffi but I figured I would post something here in case anyone has ever run into it. I get the same error when running my project, but I get the same error (as above) when simply activating the virtualenv, running a Python shell and trying as above.
This is 2.7.11 using pyenv and virtualenv on Mac OS X 10.11.4
I have libffi installed via brew
I have tried cleaning, rebuilding, reinstalling, environment variables, and more for the last four hours and can not get past this error

@reaperhulk
Copy link
Member

How did you get your Python? System, brew, python.org? Also, what pip version. If < 8.1 try upgrading and then uninstall and reinstall cffi

@carrchr
Copy link
Author

carrchr commented May 6, 2016

pip version 8.1.1
I think the 2.7.11 Python I am using was built from source and is managed via pyenv

Python 2.7.11 (default, Mar  7 2016, 16:47:50) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin

Someone from cffi commented this :

CFFI is not correctly installed: the version that it is trying to import was compiled with a different Python than the current one. That's a typical error message for UCS2 versus UCS4 Python versions.

And I was also pointed to pyenv Issue #257 and that it may have something to do with how I built the Python I am using.

@carrchr
Copy link
Author

carrchr commented May 6, 2016

Turns out that it was a "UCS2 versus UCS4 Python versions" problem. Running these commands got my project to build:

$pyenv uninstall 2.7.11
$PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" pyenv install 2.7.11

and then reinstalling pip, virtualenv, and pyenv rehash

@carrchr carrchr closed this as completed May 6, 2016
@carrchr
Copy link
Author

carrchr commented May 7, 2016

Is it worth creating a PR to add some documentation or FAQ/troubleshooting regarding this issue? CFFI did add this to their installation README - http://cffi.readthedocs.io/en/latest/installation.html#linux-and-os-x-ucs2-versus-ucs4

@reaperhulk
Copy link
Member

reaperhulk commented May 11, 2016

@carrchr Thanks for the information. I'm going to be modifying the build systems to produce both ucs2 and ucs4 wheels for cffi so that users will be able to pull the correct one. Unfortunately users on out of date pip will still pull the wrong one (as pip prior to 8 is unaware of the proper tag), but we can add some information to explain that upgrading to pip8+ will fix the issue.

@reaperhulk
Copy link
Member

A UCS4 wheel is now available so this issue should be resolved for future users on pip8+

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants