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

Fix pip install lshash for python3 #18

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

hobson
Copy link

@hobson hobson commented Nov 13, 2016

Uses PyScaffolding to add a setup.cfg file and eliminate __author__, __version__ and other constants from the __init__.py file so that setup.py doesn't have to import lshash before it has been installed.

In my python3 virtualenv on a Ubuntu 15.04 pip install lshash fails on import lshash in setup.py with this traceback:

$ pip install lshash
Collecting lshash
  Downloading lshash-0.0.4dev.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-daf7w8vx/lshash/setup.py", line 3, in <module>
        import lshash
      File "/tmp/pip-build-daf7w8vx/lshash/lshash/__init__.py", line 12, in <module>
        from lshash import LSHash
    ImportError: cannot import name 'LSHash'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-daf7w8vx/lshash/

@phdowling
Copy link

Can this be merged? Seems very useful to make this installable under python 3

@hobson
Copy link
Author

hobson commented Apr 27, 2017

This latest version is compatible with Python 2.7+ and 3.5+
I will add an lshash3 to pypi while we wait for this project to fix the official pypi package LSHash.

@samzhang111 samzhang111 mentioned this pull request May 17, 2017
@HasanBank
Copy link

So how can we install lshash to python 3 environment? I still get errors. I tried both of lshash3 and lshash3 with using pip3.
As following repo readme doc and doing pip install lshash still affects only ptyhon2 environment in my case.

@rdooley
Copy link

rdooley commented Jan 29, 2020

Can you post the output of which pip ?
If you are trying to install to the system python3 you can install with pip3

@HasanBank
Copy link

python3

Normal pip install lshash works but it installs to python 2 as a matter of course.

@loretoparisi
Copy link

loretoparisi commented May 6, 2020

@hobson I have tried lshash3 but I get an error anywas of on Python 3.7

pip install lshash3
Collecting lshash3
  Downloading https://files.pythonhosted.org/packages/51/a7/825799ea4c52ff477aae56f08b172016c434cd0264cbdd9cd7d82895bfe4/lshash3-0.0.8.tar.gz
Collecting bitarray
  Downloading https://files.pythonhosted.org/packages/3d/78/99528059e42f199910df89bd0ad8d9238f41d0499b506e0b3174340075ea/bitarray-1.2.1.tar.gz (48kB)
     |████████████████████████████████| 51kB 749kB/s 
Requirement already satisfied: numpy in /usr/local/lib/python3.7/site-packages (from lshash3) (1.18.4)
Building wheels for collected packages: lshash3, bitarray
  Building wheel for lshash3 (setup.py) ... done
  Created wheel for lshash3: filename=lshash3-0.0.8-py2.py3-none-any.whl size=10138 sha256=54282f467d07e216882d2006280fe04daee5803ef47ee537af9d5eec67eecc7e
  Stored in directory: /root/.cache/pip/wheels/30/7f/09/f8d846b30660911ca453e60d71af991bd8a506e804a7df6100
  Building wheel for bitarray (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-r4o72zc5/bitarray/setup.py'"'"'; __file__='"'"'/tmp/pip-install-r4o72zc5/bitarray/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-asj3oehx --python-tag cp37
       cwd: /tmp/pip-install-r4o72zc5/bitarray/
  Complete output (17 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/bitarray
  copying bitarray/test_bitarray.py -> build/lib.linux-x86_64-3.7/bitarray
  copying bitarray/util.py -> build/lib.linux-x86_64-3.7/bitarray
  copying bitarray/test_util.py -> build/lib.linux-x86_64-3.7/bitarray
  copying bitarray/__init__.py -> build/lib.linux-x86_64-3.7/bitarray
  running build_ext
  building 'bitarray._bitarray' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/bitarray
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -c bitarray/_bitarray.c -o build/temp.linux-x86_64-3.7/bitarray/_bitarray.o
  unable to execute 'gcc': No such file or directory
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for bitarray
  Running setup.py clean for bitarray
Successfully built lshash3
Failed to build bitarray
Installing collected packages: bitarray, lshash3
    Running setup.py install for bitarray ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-r4o72zc5/bitarray/setup.py'"'"'; __file__='"'"'/tmp/pip-install-r4o72zc5/bitarray/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-record-110ib2x9/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-r4o72zc5/bitarray/
    Complete output (17 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/bitarray
    copying bitarray/test_bitarray.py -> build/lib.linux-x86_64-3.7/bitarray
    copying bitarray/util.py -> build/lib.linux-x86_64-3.7/bitarray
    copying bitarray/test_util.py -> build/lib.linux-x86_64-3.7/bitarray
    copying bitarray/__init__.py -> build/lib.linux-x86_64-3.7/bitarray
    running build_ext
    building 'bitarray._bitarray' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/bitarray
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -c bitarray/_bitarray.c -o build/temp.linux-x86_64-3.7/bitarray/_bitarray.o
    unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-r4o72zc5/bitarray/setup.py'"'"'; __file__='"'"'/tmp/pip-install-r4o72zc5/bitarray/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-record-110ib2x9/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
WARNING: You are using pip version 19.3; however, version 20.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

@loretoparisi
Copy link

[UPDATE]
My fault, I was missing some essential

root@584e172afc7b:/app# pip install lshash3
Processing /root/.cache/pip/wheels/30/7f/09/f8d846b30660911ca453e60d71af991bd8a506e804a7df6100/lshash3-0.0.8-py2.py3-none-any.whl
Requirement already satisfied: numpy in /usr/local/lib/python3.7/site-packages (from lshash3) (1.18.4)
Collecting bitarray
  Using cached https://files.pythonhosted.org/packages/3d/78/99528059e42f199910df89bd0ad8d9238f41d0499b506e0b3174340075ea/bitarray-1.2.1.tar.gz
Building wheels for collected packages: bitarray
  Building wheel for bitarray (setup.py) ... done
  Created wheel for bitarray: filename=bitarray-1.2.1-cp37-cp37m-linux_x86_64.whl size=166467 sha256=2851409bed14aa9e2dcbd8b3a1c0fe1085ac6d9356a8b77a2d428f785d4ca288
  Stored in directory: /root/.cache/pip/wheels/8e/4f/42/90d76aca9f4a7420c8c82fe15ed949777ab3fafe9fc1d705b3
Successfully built bitarray
Installing collected packages: bitarray, lshash3
Successfully installed bitarray-1.2.1 lshash3-0.0.8

it worked after adding

RUN apt-get update && apt-get install -y --no-install-recommends \
    software-properties-common \
    build-essential

to my Dockerfile

@loretoparisi
Copy link

loretoparisi commented May 7, 2020

@hobson Not sure why but I was able to build lshash3-0.0.8.tar.gz in (/usr/local/lib/python3.7/site-packages/lshash/, but when I do import I get

Traceback (most recent call last):
  File "test_clustering_lshash.py", line 10, in <module>
    from lshash import LSHash
ImportError: cannot import name 'LSHash' from 'lshash' (/usr/local/lib/python3.7/site-packages/lshash/__init__.py)

I can see the class LSHash in file /usr/local/lib/python3.7/site-packages/lshash/lshash.py

@loretoparisi
Copy link

[UPDATE]
For whom comes to this issue, I have fixed it for Python 3.7.7. The fixed package is available here.

@p-venkatesh
Copy link

Screenshot 2020-08-07 at 10 03 00 AM

Here I am not able to import what to do, and how to import this actually?

@loretoparisi
Copy link

@p-venkatesh I have deployed a fixed and enhanced version of this package to pip here lshashpy3

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

Successfully merging this pull request may close these issues.

7 participants