question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installation error: module 'numpy.typing' has no attribute 'NDArray'

See original GitHub issue

After testing #464 which gave me errors, I noticed that I wasn’t able to reinstall ADS. After the pip install and venv activation, I get this whenever I try to run one of the CLI scripts:

Error:
Traceback (most recent call last):
  File "/home/herman/.conda/envs/ads_venv/bin/axondeepseg", line 33, in <module>
    sys.exit(load_entry_point('AxonDeepSeg', 'console_scripts', 'axondeepseg')())
  File "/home/herman/.conda/envs/ads_venv/bin/axondeepseg", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/herman/Documents/NEUROPOLY_21/axondeepseg/AxonDeepSeg/segment.py", line 28, in <module>
    from AxonDeepSeg.apply_model import axon_segmentation
  File "/home/herman/Documents/NEUROPOLY_21/axondeepseg/AxonDeepSeg/apply_model.py", line 8, in <module>
    from ivadomed import inference as imed_inference
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/ivadomed/inference.py", line 15, in <module>
    from ivadomed.loader.mri3d_subvolume_segmentation_dataset import MRI3DSubVolumeSegmentationDataset
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/ivadomed/loader/mri3d_subvolume_segmentation_dataset.py", line 8, in <module>
    from ivadomed import transforms as imed_transforms, postprocessing as imed_postpro
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/ivadomed/transforms.py", line 17, in <module>
    import torchio as tio
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/torchio/__init__.py", line 10, in <module>
    from .transforms import *  # noqa: F401, F403
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/torchio/transforms/__init__.py", line 1, in <module>
    from .transform import Transform
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/torchio/transforms/transform.py", line 13, in <module>
    from ..data.subject import Subject
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/torchio/data/__init__.py", line 1, in <module>
    from .queue import Queue
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/torchio/data/queue.py", line 10, in <module>
    from .sampler import PatchSampler
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/torchio/data/sampler/__init__.py", line 2, in <module>
    from .label import LabelSampler
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/torchio/data/sampler/label.py", line 14, in <module>
    class LabelSampler(WeightedSampler):
  File "/home/herman/.conda/envs/ads_venv/lib/python3.8/site-packages/torchio/data/sampler/label.py", line 109, in LabelSampler
    patch_size: npt.NDArray[np.uint],
AttributeError: module 'numpy.typing' has no attribute 'NDArray'

This is annoying (I don’t really have time to debug this today). Fortunately, I had another venv already setup so I can still use ADS on my laptop. It looks like a dependency problem (maybe some unpinned library was updated? not sure)

pip freeze
absl-py==0.13.0
alabaster==0.7.12
appdirs @ file:///home/conda/feedstock_root/build_artifacts/appdirs_1603108395799/work
argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1640817743617/work
argon2-cffi-bindings @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi-bindings_1649500309442/work
arrow==1.2.2
astor==0.8.1
astroid==2.9.3
asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1618968359944/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1640799537051/work
-e git+ssh://git@github.com/axondeepseg/axondeepseg.git@a800e307cfab899a55d7d60db2719c6f29184a95#egg=AxonDeepSeg
Babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1655419414885/work
backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work
backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1618230623929/work
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1649463573192/work
bids-validator==1.7.2
binaryornot==0.4.4
bleach @ file:///home/conda/feedstock_root/build_artifacts/bleach_1656355450470/work
brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1648854175163/work
cachetools==4.2.2
certifi==2020.11.8
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1656782821535/work
chardet==4.0.0
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1655906222726/work
click==8.0.1
cloudpickle @ file:///home/conda/feedstock_root/build_artifacts/cloudpickle_1653061851209/work
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1655412516417/work
commonmark==0.9.1
contextlib2 @ file:///home/conda/feedstock_root/build_artifacts/contextlib2_1624848568296/work
cookiecutter==2.1.1
coverage @ file:///home/conda/feedstock_root/build_artifacts/coverage_1654179102739/work
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography_1657174007680/work
csv-diff==1.1
cycler==0.10.0
cytoolz==0.11.2
dask @ file:///home/conda/feedstock_root/build_artifacts/dask-core_1656089485461/work
dataclasses @ file:///home/conda/feedstock_root/build_artifacts/dataclasses_1628958434797/work
debugpy @ file:///home/conda/feedstock_root/build_artifacts/debugpy_1649586349877/work
decorator==4.4.2
defusedxml @ file:///home/conda/feedstock_root/build_artifacts/defusedxml_1615232257335/work
Deprecated==1.2.13
dictdiffer==0.8.1
dill @ file:///home/conda/feedstock_root/build_artifacts/dill_1653058582944/work
docopt==0.6.2
docutils @ file:///home/conda/feedstock_root/build_artifacts/docutils_1648737565474/work
entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work
et-xmlfile==1.0.1
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1646044401614/work
fastjsonschema @ file:///home/conda/feedstock_root/build_artifacts/python-fastjsonschema_1641751198313/work/dist
file-tree @ file:///home/conda/feedstock_root/build_artifacts/file-tree_1653476294379/work
file-tree-fsl @ file:///home/conda/feedstock_root/build_artifacts/file-tree-fsl_1637872818453/work
filelock==3.0.12
flit_core @ file:///home/conda/feedstock_root/build_artifacts/flit-core_1645629044586/work/source/flit_core
formulaic==0.3.4
fsleyes @ file:///home/conda/feedstock_root/build_artifacts/fsleyes_1655300643563/work
fsleyes-props @ file:///home/conda/feedstock_root/build_artifacts/fsleyes-props_1619018550148/work
fsleyes-widgets @ file:///home/conda/feedstock_root/build_artifacts/fsleyes-widgets_1651273083908/work
fslpy @ file:///home/conda/feedstock_root/build_artifacts/fslpy_1656585277233/work
fsspec @ file:///home/conda/feedstock_root/build_artifacts/fsspec_1653010523205/work
future @ file:///home/conda/feedstock_root/build_artifacts/future_1649010148304/work
google-auth==1.32.1
google-auth-oauthlib==0.4.4
grpcio==1.38.1
h5py==2.10.0
humanize==4.2.3
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1642433548627/work
imagecodecs @ file:///home/conda/feedstock_root/build_artifacts/imagecodecs_1655137610845/work
imageio==2.9.0
imagesize @ file:///home/conda/feedstock_root/build_artifacts/imagesize_1656939531508/work
importlib-metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1653252793585/work
importlib-resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1655356668708/work
indexed-gzip @ file:///home/conda/feedstock_root/build_artifacts/indexed_gzip_1653574409039/work
iniconfig @ file:///home/conda/feedstock_root/build_artifacts/iniconfig_1603384189793/work
interface-meta==1.3.0
ipykernel @ file:///home/conda/feedstock_root/build_artifacts/ipykernel_1655369107642/work
ipython @ file:///home/conda/feedstock_root/build_artifacts/ipython_1653754926575/work
ipython-genutils==0.2.0
ipywidgets @ file:///home/conda/feedstock_root/build_artifacts/ipywidgets_1655973868664/work
isodate @ file:///home/conda/feedstock_root/build_artifacts/isodate_1639582763789/work
isort==5.10.1
ivadomed==2.9.5
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1649067097809/work
Jinja2==3.1.2
jinja2-time==0.2.0
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1633637554808/work
jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema-meta_1656454091745/work
jupyter @ file:///home/conda/feedstock_root/build_artifacts/jupyter_1637233111631/work
jupyter-client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1654730843242/work
jupyter-console @ file:///home/conda/feedstock_root/build_artifacts/jupyter_console_1655961255101/work
jupyter-core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1652365251650/work
jupyterlab-pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1649936611996/work
jupyterlab-widgets @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_widgets_1655961217661/work
kiwisolver==1.3.1
lazy-object-proxy==1.7.1
locket @ file:///home/conda/feedstock_root/build_artifacts/locket_1650660393415/work
loguru==0.6.0
Markdown==3.3.4
MarkupSafe==2.1.1
matplotlib @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-suite_1611858708474/work
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1631080358261/work
mccabe==0.6.1
mistune @ file:///home/conda/feedstock_root/build_artifacts/mistune_1635844675081/work
mpld3 @ file:///home/conda/feedstock_root/build_artifacts/mpld3_1653674415912/work
nbclient @ file:///home/conda/feedstock_root/build_artifacts/nbclient_1656688109017/work
nbconvert @ file:///home/conda/feedstock_root/build_artifacts/nbconvert-meta_1649676641343/work
nbformat @ file:///home/conda/feedstock_root/build_artifacts/nbformat_1651607001005/work
nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1648959695634/work
networkx==2.5.1
nibabel @ file:///home/conda/feedstock_root/build_artifacts/nibabel_1644264968592/work
notebook @ file:///home/conda/feedstock_root/build_artifacts/notebook_1654636967533/work
num2words==0.5.10
numpy==1.20.3
oauthlib==3.1.1
onnxruntime==1.7.0
opencv-contrib-python==4.6.0.66
opencv-python-headless==4.6.0.66
openpyxl @ file:///home/conda/feedstock_root/build_artifacts/openpyxl_1632332968451/work
packaging==20.9
pandas==1.4.3
pandocfilters @ file:///home/conda/feedstock_root/build_artifacts/pandocfilters_1631603243851/work
parse @ file:///home/conda/feedstock_root/build_artifacts/parse_1610612363844/work
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1638334955874/work
partd @ file:///home/conda/feedstock_root/build_artifacts/partd_1617910651905/work
pathlib2 @ file:///home/conda/feedstock_root/build_artifacts/pathlib2_1649684025223/work
patsy==0.5.1
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1602535608087/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1657007156214/work
pipenv==2020.11.15
platformdirs==2.5.1
pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1648772598846/work
pooch @ file:///home/conda/feedstock_root/build_artifacts/pooch_1643032624649/work
prettytable @ file:///home/conda/feedstock_root/build_artifacts/prettytable_1651787307815/work
progressbar2 @ file:///home/conda/feedstock_root/build_artifacts/progressbar2_1643742461370/work
prometheus-client @ file:///home/conda/feedstock_root/build_artifacts/prometheus_client_1649447152425/work
prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1656332401605/work
protobuf==3.20.1
psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1653089172347/work
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pure-eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1642875951954/work
py @ file:///home/conda/feedstock_root/build_artifacts/py_1636301881863/work
pyasn1==0.4.8
pyasn1-modules==0.2.8
pybids==0.15.1
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
pydicom @ file:///home/conda/feedstock_root/build_artifacts/pydicom_1648584438356/work
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1650904496387/work
pylint==2.12.2
PyOpenGL @ file:///home/conda/feedstock_root/build_artifacts/pyopengl_1652285526610/work
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1643496850550/work
pyparsing==2.4.7
Pypubsub==4.0.3
PyQt5==5.15.4
PyQt5-sip==12.9.0
pyrsistent @ file:///home/conda/feedstock_root/build_artifacts/pyrsistent_1649013354401/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1648857275402/work
pytest==7.1.2
pytest-cov @ file:///home/conda/feedstock_root/build_artifacts/pytest-cov_1633356845954/work
python-dateutil==2.8.1
python-slugify==6.1.2
python-utils @ file:///home/conda/feedstock_root/build_artifacts/python-utils_1654078983092/work
pytz==2021.1
PyWavelets==1.1.1
PyYAML==6.0
pyzmq @ file:///home/conda/feedstock_root/build_artifacts/pyzmq_1656183564873/work
qtconsole @ file:///home/conda/feedstock_root/build_artifacts/qtconsole-base_1654465674650/work
QtPy @ file:///home/conda/feedstock_root/build_artifacts/qtpy_1651524593465/work
raven==6.10.0
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1656534056640/work
requests-oauthlib==1.3.0
rich @ file:///home/conda/feedstock_root/build_artifacts/rich_1653400695283/work
rsa==4.7.2
Rtree @ file:///home/conda/feedstock_root/build_artifacts/rtree_1649367609955/work
scikit-image @ file:///home/conda/feedstock_root/build_artifacts/scikit-image_1638363134145/work
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1639497510391/work
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy_1653073867187/work
seaborn==0.11.2
Send2Trash @ file:///home/conda/feedstock_root/build_artifacts/send2trash_1628511208346/work
SimpleITK==2.1.1.2
sip @ file:///home/conda/feedstock_root/build_artifacts/sip_1646101181167/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
snowballstemmer @ file:///home/conda/feedstock_root/build_artifacts/snowballstemmer_1637143057757/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1638550740809/work
Sphinx @ file:///home/conda/feedstock_root/build_artifacts/sphinx_1655452194084/work
sphinx-rtd-theme @ file:///home/conda/feedstock_root/build_artifacts/sphinx_rtd_theme_1617698677674/work
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-htmlhelp_1621704829796/work
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-serializinghtml_1649380998999/work
SQLAlchemy==1.3.24
stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1655315839047/work
tabulate @ file:///home/conda/feedstock_root/build_artifacts/tabulate_1655900837660/work
tensorboard==2.9.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.0
terminado @ file:///home/conda/feedstock_root/build_artifacts/terminado_1652790603425/work
text-unidecode==1.3
textual @ file:///home/conda/feedstock_root/build_artifacts/textual_1653135219208/work
threadpoolctl==2.2.0
tifffile==2021.7.2
tinycss2 @ file:///home/conda/feedstock_root/build_artifacts/tinycss2_1637612658783/work
toml==0.10.2
tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1644342247877/work
toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1636177962100/work
torch==1.8.1+cpu
torchio==0.18.82
torchvision==0.9.1+cpu
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1656937829196/work
tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1649051611147/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1655411388954/work
trimesh @ file:///home/conda/feedstock_root/build_artifacts/trimesh_1651880120104/work
typing_extensions==4.1.1
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1647489083693/work
virtualenv-clone==0.5.4
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work
webencodings==0.5.1
Werkzeug==2.0.1
widgetsnbextension @ file:///home/conda/feedstock_root/build_artifacts/widgetsnbextension_1655939017940/work
wrapt==1.13.3
wxnatpy @ file:///home/conda/feedstock_root/build_artifacts/wxnatpy_1633683489436/work
wxPython==4.1.1
xarray @ file:///home/conda/feedstock_root/build_artifacts/xarray_1646254587173/work
xnat @ file:///home/conda/feedstock_root/build_artifacts/xnat_1649668041065/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1649012893348/work

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
hermancollincommented, Jul 11, 2022

The stranger thing (hehe) about this is that our linux CI isn’t catching this issue, so it really sounds something on your end.

Yes, I agree. I deleted the venv, reinstalled everything for the 100th time and it finally works. Not sure what happened but I’ll close this now.

1reaction
mathieuboudreaucommented, Jul 11, 2022

I think I’ll try to reinstall the whole environment again and see if the problem persists and I’ll have to uninstall numpy everytime to make it work.

Can you check what version you’re uninstalling in your env? Maybe fixing it to 1.23.x in the installation would be a better solution if that’s the case?

The stranger thing (hehe) about this is that our linux CI isn’t catching this issue, so it really sounds something on your end. To be really sure, if you can, maybe you could create a new temporary user in your OS so that your really start with a “clean” installation. If it works there and not in your regular OS user, then it might just be a quirk in your current setup 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: type object 'numpy.ndarray' has no attribute ' ...
Best way to resolve this problem is first uninstall numpy using pip3 pip3 uninstall numpy. then install ...
Read more >
AttributeError type object numpy ndarray has no attribute ...
Hi Guys, I installed numpy module in my system. But when I tried to import this module in python prompt, I got this...
Read more >
AttributeError module 'numpy' has no attribute 'array'
The Python "AttributeError module 'numpy' has no attribute 'array'" occurs when we have a local file named numpy.py and try to import from...
Read more >
QST: import pandas AttributeError: module 'numpy' has no ...
I tried pip install although I use anaconda and did not work pip ... pandas AttributeError: module 'numpy' has no attribute 'ndarray' #39243....
Read more >
Typing (numpy.typing) — NumPy v1.24 Manual
Users who want to write statically typed code should instead use the numpy.ndarray.view method to create a view of the array with a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found