GrahamDumpleton / wrapt

A Python module for decorators, wrappers and monkey patching.
BSD 2-Clause "Simplified" License
2.04k stars 230 forks source link

No module named 'wrapt' #199

Closed dongyun-kim-arch closed 2 years ago

dongyun-kim-arch commented 2 years ago

Hi!

I face the issue, No module named 'wrapt', even though I already installed wrapt package. conda install wrapt pip3 install -U --no-cache-dir wrapt didn't help me.

This is my libraries.

absl-py==0.15.0 albumentations==1.0.0 astunparse==1.6.3 cachetools==4.2.4 certifi==2021.10.8 charset-normalizer==2.0.7 cv==1.0.0 cycler==0.11.0 flatbuffers==1.12 fonttools==4.28.1 gast==0.3.3 google-auth==2.3.3 google-auth-oauthlib==0.4.6 google-pasta==0.2.0 grpcio==1.32.0 h5py==2.10.0 idna==3.3 imageio==2.11.0 importlib-metadata==4.8.2 keras==2.7.0 Keras-Preprocessing==1.1.2 kiwisolver==1.3.2 libclang==12.0.0 Markdown==3.3.6 matplotlib==3.5.0 mkl-fft==1.3.1 mkl-random @ file:///C:/ci/mkl_random_1626186163140/work mkl-service==2.4.0 monotonic==1.6 netifaces==0.11.0 networkx==2.6.3 numpy @ file:///C:/ci/numpy_and_numpy_base_1634106873805/work oauthlib==3.1.1 olefile==0.46 opencv-python==4.5.4.58 opencv-python-headless==4.5.4.58 opt-einsum==3.3.0 packaging==21.3 Pillow==8.4.0 protobuf==3.19.1 pyasn1==0.4.8 pyasn1-modules==0.2.8 pyparsing==3.0.6 python-dateutil==2.8.2 PyWavelets==1.2.0 PyYAML==6.0 requests==2.26.0 requests-oauthlib==1.3.0 rsa==4.7.2 scikit-image==0.18.3 scipy==1.7.2 setuptools-scm==6.3.2 six @ file:///tmp/build/80754af9/six_1623709665295/work tensorboard==2.7.0 tensorboard-data-server==0.6.1 tensorboard-plugin-wit==1.8.0 tensorflow==2.7.0 tensorflow-estimator==2.7.0 tensorflow-gpu==2.7.0 tensorflow-io-gcs-filesystem==0.22.0 termcolor==1.1.0 tifffile==2021.11.2 tomli==1.2.2 typing-extensions==3.7.4.3 urllib3==1.26.7 Werkzeug==2.0.2 wincertstore==0.2 wrapt==1.13.3 zipp==3.6.0

GrahamDumpleton commented 2 years ago

Can you provide a directory listing for the site-packages directory of the virtual environment or Python installation where wrapt is installed?

dongyun-kim-arch commented 2 years ago

How could I check it?

C:\WINDOWS\system32>python -m site --user-site C:\Users\Lei\AppData\Roaming\Python\Python37\site-packages

dongyun-kim-arch commented 2 years ago

C:\Users\Lei>pip install wrapt --user Requirement already satisfied: wrapt in c:\users\lei\anaconda3\envs\pritzker\lib\site-packages (1.13.3)

GrahamDumpleton commented 2 years ago

You appear to have things installed in multiple places and are mixing up what Python environment you are using when installing vs running. Uninstall the package from everywhere it may be installed.

Ensuring you have correct virtual environments activated as necessary, run:

conda uninstall wrapt
pip uninstall wrapt
pip uninstall --user wrapt

Then for only the Python virtual environment you are using, run:

pip install --no-cache-dir wrapt

Do not use pip install --user as it gets installed in a location where it will be ignored if you are using a virtual environment.

dongyun-kim-arch commented 2 years ago

I see. It seems I installed wrapt in multiple places. So, I tried to uninstall wrapt, but it throws this error...

C:\Users\Lei>pip uninstall wrapt Found existing installation: wrapt 1.12.1 ERROR: Cannot uninstall wrapt 1.12.1, RECORD file not found. You might be able to recover from this via: 'pip install --force-reinstall --no-deps wrapt==1.12.1'.

GrahamDumpleton commented 2 years ago

It is perfectly fine if some of those fail. I only provided them all to try and capture all the different ways it could have been installed.

dongyun-kim-arch commented 2 years ago

it seems there is wrapt which didn't uninstall.. I think the problem might come from here....?

C:\Users\Lei>pip install --no-cache-dir wrapt Requirement already satisfied: wrapt in c:\users\lei\anaconda3\envs\pritzker\lib\site-packages (1.12.1) ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'c:\users\lei\anaconda3\envs\pritzker\lib\site-packages\wrapt-1.12.1.dist-info\METADATA'

GrahamDumpleton commented 2 years ago

What happens if you try again to uninstall wrapt using conda? And then install using conda?

dongyun-kim-arch commented 2 years ago

When I uninstall wrapt,

C:\Users\Lei>conda uninstall wrapt Collecting package metadata (repodata.json): done Solving environment: failed

PackagesNotFoundError: The following packages are missing from the target environment:

and when I install wrapt using conda

C:\Users\Lei>conda install wrapt Collecting package metadata (current_repodata.json): done Solving environment: done

Package Plan

environment location: C:\Users\Lei\anaconda3\envs\pritzker

added / updated specs:

The following NEW packages will be INSTALLED:

wrapt pkgs/main/win-64::wrapt-1.12.1-py37he774522_1

Proceed ([y]/n)? y

Preparing transaction: done Verifying transaction: done Executing transaction: done

GrahamDumpleton commented 2 years ago

So conda uses an older wrapt version. Try using that and don't use pip to install it.

Somewhere along the way conda/pip are confusing each other. Why I don't know.

dongyun-kim-arch commented 2 years ago

I think the problem is.. although I uninstall wrapt using pip and conda, it wasn't uninstalled ... and I guess, it causes the problem, No module named 'wrapt'..... this is what I can see when I uninstall wrapt with pip and conda and my pip freeze

C:\Users\Lei>pip uninstall wrapt Found existing installation: wrapt 1.12.1 ERROR: Cannot uninstall wrapt 1.12.1, RECORD file not found. You might be able to recover from this via: 'pip install --force-reinstall --no-deps wrapt==1.12.1'.

(pritzker) C:\Users\Lei>conda uninstall wrapt Collecting package metadata (repodata.json): done Solving environment: failed

PackagesNotFoundError: The following packages are missing from the target environment:

(pritzker) C:\Users\Lei>pip freeze WARNING: No metadata found in c:\users\lei\anaconda3\envs\pritzker\lib\site-packages WARNING: No metadata found in c:\users\lei\anaconda3\envs\pritzker\lib\site-packages absl-py==0.15.0 albumentations==1.0.0 astunparse==1.6.3 cachetools==4.2.4 certifi==2021.10.8 charset-normalizer==2.0.7 cv==1.0.0 cycler==0.11.0 flatbuffers==1.12 fonttools==4.28.1 gast==0.3.3 google-auth==2.3.3 google-auth-oauthlib==0.4.6 google-pasta==0.2.0 grpcio==1.32.0 h5py==2.10.0 idna==3.3 imageio==2.11.0 importlib-metadata==4.8.2 keras==2.7.0 keras-nightly==2.8.0.dev2021111808 Keras-Preprocessing==1.1.2 kiwisolver==1.3.2 libclang==12.0.0 Markdown==3.3.6 matplotlib==3.5.0 mkl-fft==1.3.1 mkl-random @ file:///C:/ci/mkl_random_1626186163140/work mkl-service==2.4.0 monotonic==1.6 netifaces==0.11.0 networkx==2.6.3 numpy @ file:///C:/ci/numpy_and_numpy_base_1634106873805/work oauthlib==3.1.1 olefile==0.46 opencv-python==4.5.4.58 opencv-python-headless==4.5.4.58 opt-einsum==3.3.0 packaging==21.3 Pillow==8.4.0 protobuf==3.19.1 pyasn1==0.4.8 pyasn1-modules==0.2.8 pyparsing==3.0.6 python-dateutil==2.8.2 PyWavelets==1.2.0 PyYAML==6.0 requests==2.26.0 requests-oauthlib==1.3.0 rsa==4.7.2 scikit-image==0.18.3 scipy==1.7.2 setuptools-scm==6.3.2 six @ file:///tmp/build/80754af9/six_1623709665295/work tb-nightly==2.8.0a20211117 tensorboard==2.7.0 tensorboard-data-server==0.6.1 tensorboard-plugin-wit==1.8.0 tensorflow==2.7.0 tensorflow-estimator==2.7.0 tensorflow-gpu==2.7.0 tensorflow-io-gcs-filesystem==0.22.0 termcolor==1.1.0 tf-estimator-nightly==2.8.0.dev2021111809 tf-nightly-gpu==2.8.0.dev20211118 tifffile==2021.11.2 tomli==1.2.2 typing-extensions==3.7.4.3 urllib3==1.26.7 Werkzeug==2.0.2 wincertstore==0.2 wrapt==1.12.1 zipp==3.6.0

GrahamDumpleton commented 2 years ago

Sorry, I have no idea. Can only suggest you ask on StackOverflow.

ongtw commented 2 years ago

I am also experiencing the same weird error of wrapt requiring wrapt... 🤔

~ ❯ pip3 list
Cython (0.29.26)
numpy (1.19.5)
pbr (5.8.0)
pip (9.0.1)
pkg-resources (0.0.0)
setuptools (39.0.1)
testresources (2.0.1)
~ ❯ pip3 install -U wrapt
Collecting wrapt
  Using cached https://files.pythonhosted.org/packages/eb/f6/d81ccf43ac2a3c80ddb6647653ac8b53ce2d65796029369923be06b815b8/wrapt-1.13.3.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-953dqbmc/wrapt/setup.py", line 42, in <module>
        ext_modules=[] if disable_extensions else extensions
      File "/home/aisg/pkd36_1/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.6/distutils/core.py", line 121, in setup
        dist.parse_config_files()
      File "/home/aisg/pkd36_1/lib/python3.6/site-packages/setuptools/dist.py", line 494, in parse_config_files
        ignore_option_errors=ignore_option_errors)
      File "/home/aisg/pkd36_1/lib/python3.6/site-packages/setuptools/config.py", line 106, in parse_configuration
        meta.parse()
      File "/home/aisg/pkd36_1/lib/python3.6/site-packages/setuptools/config.py", line 382, in parse
        section_parser_method(section_options)
      File "/home/aisg/pkd36_1/lib/python3.6/site-packages/setuptools/config.py", line 355, in parse_section
        self[name] = value
      File "/home/aisg/pkd36_1/lib/python3.6/site-packages/setuptools/config.py", line 173, in __setitem__
        value = parser(value)
      File "/home/aisg/pkd36_1/lib/python3.6/site-packages/setuptools/config.py", line 430, in _parse_version
        version = self._parse_attr(value)
      File "/home/aisg/pkd36_1/lib/python3.6/site-packages/setuptools/config.py", line 305, in _parse_attr
        module = import_module(module_name)
      File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'wrapt'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-953dqbmc/wrapt/
~ ❯

Any help/suggestions would be greatly appreciated.

sliwinski-milosz commented 2 years ago

I have faced this issue while using docker-compose on MacBook Pro M1. Adding platform: linux/x86_64 to the docker-compose yml file has helped.

The pip turned from:

#28 6.191 Collecting wrapt==1.13.3
#28 6.226   Downloading wrapt-1.13.3.tar.gz (48 kB)
#28 6.231      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 KB 13.0 MB/s eta 0:00:00
#28 6.241   Preparing metadata (setup.py): started
#28 6.315   Preparing metadata (setup.py): finished with status 'error'
#28 6.319   error: subprocess-exited-with-error
#28 6.319
#28 6.319   × python setup.py egg_info did not run successfully.
#28 6.319   │ exit code: 1
#28 6.319   ╰─> [29 lines of output]
#28 6.319       Traceback (most recent call last):
#28 6.319         File "<string>", line 2, in <module>
#28 6.319         File "<pip-setuptools-caller>", line 34, in <module>
#28 6.319         File "/tmp/pip-install-yduh9lkj/wrapt_20ab1b1e8bca4ae6b181307daa26c007/setup.py", line 41, in <module>
#28 6.319           setuptools.setup(
#28 6.319         File "/opt/some_company/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 129, in setup
#28 6.319           return distutils.core.setup(**attrs)
#28 6.319         File "/usr/lib/python3.8/distutils/core.py", line 121, in setup
#28 6.319           dist.parse_config_files()
#28 6.319         File "/opt/some_company/venv/lib/python3.8/site-packages/setuptools/dist.py", line 493, in parse_config_files
#28 6.319           parse_configuration(self, self.command_options,
#28 6.319         File "/opt/some_company/venv/lib/python3.8/site-packages/setuptools/config.py", line 106, in parse_configuration
#28 6.319           meta.parse()
#28 6.319         File "/opt/some_company/venv/lib/python3.8/site-packages/setuptools/config.py", line 382, in parse
#28 6.319           section_parser_method(section_options)
#28 6.319         File "/opt/some_company/venv/lib/python3.8/site-packages/setuptools/config.py", line 355, in parse_section
#28 6.319           self[name] = value
#28 6.319         File "/opt/some_company/venv/lib/python3.8/site-packages/setuptools/config.py", line 173, in __setitem__
#28 6.319           value = parser(value)
#28 6.319         File "/opt/some_company/venv/lib/python3.8/site-packages/setuptools/config.py", line 430, in _parse_version
#28 6.319           version = self._parse_attr(value)
#28 6.319         File "/opt/some_company/venv/lib/python3.8/site-packages/setuptools/config.py", line 305, in _parse_attr
#28 6.319           module = import_module(module_name)
#28 6.319         File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
#28 6.319           return _bootstrap._gcd_import(name[level:], package, level)
#28 6.319         File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
#28 6.319         File "<frozen importlib._bootstrap>", line 991, in _find_and_load
#28 6.319         File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
#28 6.319       ModuleNotFoundError: No module named 'wrapt'
#28 6.319       [end of output]
#28 6.319
#28 6.319   note: This error originates from a subprocess, and is likely not a problem with pip.
#28 6.320 error: metadata-generation-failed
#28 6.320
#28 6.320 × Encountered error while generating package metadata.
#28 6.320 ╰─> See above for output.

into:

#28 25.31 Collecting wrapt==1.13.3
#28 25.35   Downloading wrapt-1.13.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (84 kB)
#28 25.37      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.6/84.6 KB 8.4 MB/s eta 0:00:00

So it seems that there is a problem in building the wrapt from source. However it is able to install it from wheel if it is available for your system.

GrahamDumpleton commented 2 years ago

You need to have a compiler available if using ARM. If you don't you need to have environment variable WRAPT_INSTALL_EXTENSIONS=false set. This is distinct from original issue which was a Windows issue.

GrahamDumpleton commented 2 years ago

Going to close this issue at this point. Version 1.14.0 has binary wheels for ARM on macOS and Linux, which are what latter commenters were raising. The original problem was unrelated to those latter comments, was Windows specific and more to do with the users setup by the look of it.