Unable to install apex-ModuleNotFoundError: No module named 'packaging'
Environment
- OS: Ubuntu 20.04
- Kernel Version: 5.4.0-216
- Compiler: GCC 9.4.0
- CONDA Environment: PyTorch 1.7.1; torchvision 0.8.2; CUDA 10.1; Python Version: 3.7; pip Version: 22.3.1
Describe the problem
I encountered a ModuleNotFoundError: No module named 'packaging'error when trying to install Apex from source using the following command:
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
The installation process fails during the "Getting requirements to build wheel" phase, even though the packagingmodule is already installed in my environment. The output are below
Using pip 22.3.1 from /data/home/zsj/anaconda3/envs/stvit-r/lib/python3.7/site-packages/pip (python 3.7)
WARNING: Implying --no-binary=:all: due to the presence of --build-option / --global-option / --install-option. Consider using --config-settings for more flexibility.
DEPRECATION: --no-binary currently disables reading from the cache of locally built wheels. In the future --no-binary will not influence the wheel cache. pip 23.1 will enforce this behaviour change. A possible replacement is to use the --no-cache-dir option. You can use the flag --use-feature=no-binary-enable-wheel-cache to test the upcoming behaviour. Discussion can be found at https://github.com/pypa/pip/issues/11453
Processing /data/home/zsj/STViT-R/apex
Running command pip subprocess to install build dependencies
DEPRECATION: --no-binary currently disables reading from the cache of locally built wheels. In the future --no-binary will not influence the wheel cache. pip 23.1 will enforce this behaviour change. A possible replacement is to use the --no-cache-dir option. You can use the flag --use-feature=no-binary-enable-wheel-cache to test the upcoming behaviour. Discussion can be found at https://github.com/pypa/pip/issues/11453
Collecting setuptools
Using cached setuptools-68.0.0.tar.gz (2.2 MB)
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting wheel
Using cached wheel-0.42.0.tar.gz (98 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: wheel, setuptools
Building wheel for wheel (pyproject.toml): started
Building wheel for wheel (pyproject.toml): finished with status 'done'
Created wheel for wheel: filename=wheel-0.42.0-py3-none-any.whl size=65424 sha256=24c575334f424badc62a864ead85c9d8b1d0591c9d6f90fcdc92df4242107c6e
Stored in directory: /data/home/zsj/.cache/pip/wheels/9c/7c/d4/f80400a354bbdf027e7c25f1ab9fe54cb335ffd250856d2ed7
Building wheel for setuptools (pyproject.toml): started
Building wheel for setuptools (pyproject.toml): finished with status 'done'
Created wheel for setuptools: filename=setuptools-68.0.0-py3-none-any.whl size=804030 sha256=67eab5afda219ece9bd8474482dfd8629c7932fdb1f2c9e5a0500493ced31308
Stored in directory: /data/home/zsj/.cache/pip/wheels/a3/c6/e0/3068d92761531b10ed41a2d0ef2d3110b24856a0383c168a5a
Successfully built wheel setuptools
Installing collected packages: wheel, setuptools
Successfully installed setuptools-68.0.0 wheel-0.42.0
Installing build dependencies ... done
Running command Getting requirements to build wheel
Traceback (most recent call last):
File "/data/home/zsj/anaconda3/envs/stvit-r/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
main()
File "/data/home/zsj/anaconda3/envs/stvit-r/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/data/home/zsj/anaconda3/envs/stvit-r/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-8920qfx6/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-8920qfx6/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-8920qfx6/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in run_setup
exec(code, locals())
File "<string>", line 6, in <module>
ModuleNotFoundError: No module named 'packaging'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /data/home/zsj/anaconda3/envs/stvit-r/bin/python /data/home/zsj/anaconda3/envs/stvit-r/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpljarohtz
cwd: /data/home/zsj/STViT-R/apex
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
Additional Information
I've verified that the packagingmodule is already installed in my environment. I've saw the same porblem in https://github.com/NVIDIA/apex/issues/1737#issuecomment-1762662648 and others. But they seems not work in my situation.
This problem has been troubling me several days. I'd really appreciated if someone could help me figure out this problem.🥺
This problem has been troubling me several days. I'd really appreciated if someone could help me figure out this problem.🥺
pip install packaging