pyranges/sorted_nearest

ImportError: cannot import name 'get_all_ties'

soymintc opened this issue · 8 comments

Hi,

When I create a venv either using python -m venv or conda create, on both python3.7 and python3.9, I get the following ImportError:

Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
m>>> import sorted_nearest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/juno/work/shah/users/chois7/envs/qu37/lib/python3.7/site-packages/sorted_nearest/__init__.py", line 7, in <module>
    from sorted_nearest.src.k_nearest_ties import get_all_ties, get_different_ties
ImportError: cannot import name 'get_all_ties' from 'sorted_nearest.src.k_nearest_ties' (/juno/work/shah/users/chois7/envs/qu37/lib/python3.7/site-packages/sorted_nearest/src/k_nearest_ties.cpython-37m-x86_64-linux-gnu.so)

I've listed only one error message from a python3.7 conda environment, but the same ImportError appears whenever I try to import the package. The environments I tested were newly created, so I believe this is highly likely an error due to packaging... but correct me if I'm wrong. Thanks.

FYI I put in some part of my screen if this helps:

chois7@ceto:envs$ conda create -p /juno/work/shah/users/chois7/envs/qu37 python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.12.0
  latest version: 4.13.0

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /juno/work/shah/users/chois7/envs/qu37

  added / updated specs:
    - python=3.7


The following NEW packages will be INSTALLED:

  _libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
  _openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-2_gnu
  ca-certificates    conda-forge/linux-64::ca-certificates-2022.5.18.1-ha878542_0
  ld_impl_linux-64   conda-forge/linux-64::ld_impl_linux-64-2.36.1-hea4e1c9_2
  libffi             conda-forge/linux-64::libffi-3.4.2-h7f98852_5
  libgcc-ng          conda-forge/linux-64::libgcc-ng-12.1.0-h8d9b700_16
  libgomp            conda-forge/linux-64::libgomp-12.1.0-h8d9b700_16
  libnsl             conda-forge/linux-64::libnsl-2.0.0-h7f98852_0
  libstdcxx-ng       conda-forge/linux-64::libstdcxx-ng-12.1.0-ha89aaad_16
  libzlib            conda-forge/linux-64::libzlib-1.2.11-h166bdaf_1014
  ncurses            conda-forge/linux-64::ncurses-6.3-h27087fc_1
  openssl            conda-forge/linux-64::openssl-3.0.3-h166bdaf_0
  pip                conda-forge/noarch::pip-22.1.1-pyhd8ed1ab_0
  python             conda-forge/linux-64::python-3.7.12-hf930737_100_cpython
  python_abi         conda-forge/linux-64::python_abi-3.7-2_cp37m
  readline           conda-forge/linux-64::readline-8.1-h46c0cb4_0
  setuptools         conda-forge/linux-64::setuptools-62.3.2-py37h89c1867_0
  sqlite             conda-forge/linux-64::sqlite-3.38.5-h4ff8645_0
  tk                 conda-forge/linux-64::tk-8.6.12-h27826a3_0
  wheel              conda-forge/noarch::wheel-0.37.1-pyhd8ed1ab_0
  xz                 conda-forge/linux-64::xz-5.2.5-h516909a_1
  zlib               conda-forge/linux-64::zlib-1.2.11-h166bdaf_1014


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate /juno/work/shah/users/chois7/envs/qu37
#
# To deactivate an active environment, use
#
#     $ conda deactivate

chois7@ceto:envs$ conda activate /juno/work/shah/users/chois7/envs/qu37
(qu37) chois7@ceto:envs$ pip freeze
(qu37) chois7@ceto:envs$ pip install sorted_nearest
Collecting sorted_nearest
  Using cached sorted_nearest-0.0.35.tar.gz (1.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy
  Using cached numpy-1.21.6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
Collecting cython
  Using cached Cython-0.29.30-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.9 MB)
Building wheels for collected packages: sorted_nearest
  Building wheel for sorted_nearest (pyproject.toml) ... done
  Created wheel for sorted_nearest: filename=sorted_nearest-0.0.35-cp37-cp37m-linux_x86_64.whl size=4760457 sha256=76381b55ab402d9545ad1a27892e0a7390dd2fa7f9aeb3cf740dda54afd528b3
  Stored in directory: /juno/work/shah/users/chois7/.cache/wheels/12/45/3b/46f230ccf3effba9141fc3ff94b3087b049bd88215f8bf8e1f
Successfully built sorted_nearest
Installing collected packages: numpy, cython, sorted_nearest
Successfully installed cython-0.29.30 numpy-1.21.6 sorted_nearest-0.0.35
(qu37) chois7@ceto:envs$ python
Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sorted_nearest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/juno/work/shah/users/chois7/envs/qu37/lib/python3.7/site-packages/sorted_nearest/__init__.py", line 7, in <module>
    from sorted_nearest.src.k_nearest_ties import get_all_ties, get_different_ties
ImportError: cannot import name 'get_all_ties' from 'sorted_nearest.src.k_nearest_ties' (/juno/work/shah/users/chois7/envs/qu37/lib/python3.7/site-packages/sorted_nearest/src/k_nearest_ties.cpython-37m-x86_64-linux-gnu.so)

I've managed to work around the problem by installing the 0.0.33 version though

I've managed to work around the problem by installing the 0.0.33 version though

Thank you for sharing your solution. I was having the same problem.

I'm on it

I can reproduce:

In [1]: import sorted_nearest
sorted_---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-a0ea713684bf> in <module>
----> 1 import sorted_nearest

~/anaconda3/lib/python3.8/site-packages/sorted_nearest/__init__.py in <module>
      5 from sorted_nearest.src.k_nearest import k_nearest_previous_nonoverlapping, k_nearest_next_nonoverlapping
      6
----> 7 from sorted_nearest.src.k_nearest_ties import get_all_ties, get_different_ties
      8
      9 from sorted_nearest.src.tiles import maketiles

ImportError: cannot import name 'get_all_ties' from 'sorted_nearest.src.k_nearest_ties' (/Users/endrebakkenstovner/anaconda3/lib/python3.8/site-packages/sorted_nearest/src/k_nearest_ties.cpython-38-darwin.so)

This is weird. Installing from PyPI errors like above, but installing 0.0.35 with python setup.py install works.

I uploaded 0.0.37 now, does it work for you? pip install sorted_nearest==0.0.37 --no-cache-dir; python -c "import sorted_nearest"

@endrebak It works; thank you so much! Now I guess I can use packages that have dependencies for sorted_nearest without errors.

chois7@juno:envs$ python -m venv test
chois7@juno:envs$ source test/bin/activate
(test) chois7@juno:envs$ pip install sorted_nearest==0.0.37 --no-cache-dir; python -c "import sorted_nearest"
Collecting sorted_nearest==0.0.37
  Downloading sorted_nearest-0.0.37.tar.gz (1.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 12.7 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy
  Downloading numpy-1.22.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.8/16.8 MB 117.4 MB/s eta 0:00:00
Collecting cython
  Downloading Cython-0.29.30-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (2.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 186.6 MB/s eta 0:00:00
Building wheels for collected packages: sorted_nearest
  Building wheel for sorted_nearest (pyproject.toml) ... done
  Created wheel for sorted_nearest: filename=sorted_nearest-0.0.37-cp39-cp39-linux_x86_64.whl size=2160360 sha256=5456d8b776c6ad371784a4d9f007ed7fcf5990dae00aaf7c93f7867d982a073a
  Stored in directory: /juno/work/shah/users/chois7/tmp/pip-ephem-wheel-cache-lajab62b/wheels/c2/d7/00/b1f7073f277f0795d10c2a6f23a8a2b7d7f36091771459746b
Successfully built sorted_nearest
Installing collected packages: numpy, cython, sorted_nearest
Successfully installed cython-0.29.30 numpy-1.22.4 sorted_nearest-0.0.37
WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
You should consider upgrading via the '/juno/work/shah/users/chois7/envs/test/bin/python -m pip install --upgrade pip' command.
(test) chois7@juno:envs$ python -c "import sorted_nearest"
(test) chois7@juno:envs$

No, thanks to you all for reporting :D