'Can't install python package-error in virtualenv: command 'x86_64-linux-gnu-gcc' failed with exit status 1
I am using python in windows subsystem ubuntu 20.04.3, I created a virtual environment and installed python 3.7 (ubuntu system has python 3.8), I need to install the python package torch-sparse, however, after I ran pip install torch-scatter -f https://data.pyg.org/whl/torch-1.4.0+cpu.html, I had following error:
/home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/aten_interned_strings.h:1001:9: note: ‘c10::attr::value’ declared here
1001 | _(attr, value) \
| ^~~~~
/home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/interned_strings.h:373:35: note: in definition of macro ‘DEFINE_SYMBOL’
373 | namespace ns { constexpr Symbol s(static_cast<unique_t>(_keys::ns##_##s)); }
| ^
/home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/interned_strings.h:204:3: note: in expansion of macro ‘FORALL_ATTR_BASE_SYMBOLS’
204 | FORALL_ATTR_BASE_SYMBOLS(_) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
/home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/interned_strings.h:374:1: note: in expansion of macro ‘FORALL_NS_SYMBOLS’
374 | FORALL_NS_SYMBOLS(DEFINE_SYMBOL)
| ^~~~~~~~~~~~~~~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
---------------------------------------- ERROR: Command errored out with exit status 1: /home/alva/python/foo-3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bd2qx3dj/torch-sparse/setup.py'"'"';
__file__='"'"'/tmp/pip-install-bd2qx3dj/torch-sparse/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-ppnxm3yh/install-record.txt
--single-version-externally-managed --compile --install-headers /home/alva/python/foo-3.7/include/site/python3.7/torch-sparse Check the logs for full command output. WARNING: You are using pip version
20.1.1; however, version 22.0.3 is available. You should consider upgrading via the '/home/alva/python/foo-3.7/bin/python3.7 -m pip install --upgrade pip' command.
and
In file included from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/Dimname.h:5,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/NamedTensor.h:4,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/TensorBody.h:20,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/Tensor.h:11,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/Context.h:4,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/ATen.h:5,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4,
from /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/torch/extension.h:4,
from csrc/cpu/convert_cpu.h:3,
from csrc/cpu/convert_cpu.cpp:1: /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/aten_interned_strings.h:1001:9: note: ‘c10::attr::value’ declared here 1001 | _(attr, value) \
| ^~~~~ /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/interned_strings.h:373:35: note: in definition of macro ‘DEFINE_SYMBOL’
373 | namespace ns { constexpr Symbol s(static_cast<unique_t>(_keys::ns##_##s)); }
| ^ /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/interned_strings.h:204:3: note: in expansion of macro ‘FORALL_ATTR_BASE_SYMBOLS’
204 | FORALL_ATTR_BASE_SYMBOLS(_) \
| ^~~~~~~~~~~~~~~~~~~~~~~~ /home/alva/python/foo-3.7/lib/python3.7/site-packages/torch/include/ATen/core/interned_strings.h:374:1: note: in expansion of macro ‘FORALL_NS_SYMBOLS’
374 | FORALL_NS_SYMBOLS(DEFINE_SYMBOL)
| ^~~~~~~~~~~~~~~~~ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- ERROR: Failed building wheel for torch-sparse
I tried codes
sudo apt-get install python3.7-dev
sudo apt-get install libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev
sudo apt-get install python3.7-dev
sudo apt install build-essential
pip install torch-sparse -f https://data.pyg.org/whl/torch-1.4.0/torch_sparse-0.5.1+cpu-cp37-cp37m-linux_x86_64.whl
But I still get the same error. I have torch 1.4.0+cpu but I don't think torch version is the problem.
How can I get rid of this error? Thanks so much in advance.
Solution 1:[1]
Hello I finally solved my issue, so I post my solution here.
First I need to clarify that I need to install torch-sparse, and there's typo in my command(I copy paste the code for torch-scatter by mistake). But the error message is correct.
What I did is that I unintalled ubuntu 20.04 and installed ubuntu 18.04, which has default python 3.6.9. Then I proceed to create a virtualenv using default python version, and just use pip install torch-sparse==0.5.1 and it works now.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alva Lindy |
