DSE-MSU / DeepRobust

A pytorch adversarial library for attack and defense methods on images and graphs
MIT License
994 stars 192 forks source link

error during installation windows 11 #141

Open primimazza opened 1 year ago

primimazza commented 1 year ago
  AttributeError: 'dict' object has no attribute '__NUMPY_SETUP__'
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

ChandlerBang commented 1 year ago

Can you provide more about the error log?

primimazza commented 1 year ago

C:\Users\Administrator>pip install deeprobust Requirement already satisfied: deeprobust in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages\deeprobust-0.2.7-py3.10.egg (0.2.7) Collecting matplotlib>=3.1.1 (from deeprobust) Using cached matplotlib-3.7.1-cp310-cp310-win_amd64.whl (7.6 MB) Requirement already satisfied: numpy>=1.17.1 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from deeprobust) (1.23.4) Requirement already satisfied: torch>=1.2.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from deeprobust) (2.0.1) Requirement already satisfied: scipy>=1.3.1 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from deeprobust) (1.11.0) Collecting torchvision>=0.4.0 (from deeprobust) Using cached torchvision-0.15.2-cp310-cp310-win_amd64.whl (1.2 MB) Collecting texttable>=1.6.2 (from deeprobust) Using cached texttable-1.6.7-py2.py3-none-any.whl (10 kB) Requirement already satisfied: networkx>=2.4 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from deeprobust) (3.1) Collecting numba>=0.48.0 (from deeprobust) Using cached numba-0.57.1-cp310-cp310-win_amd64.whl (2.5 MB) Collecting Pillow>=7.0.0 (from deeprobust) Using cached Pillow-9.5.0-cp310-cp310-win_amd64.whl (2.5 MB) Requirement already satisfied: scikit_learn>=0.22.1 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from deeprobust) (1.2.2) Collecting scikit-image>=0.0 (from deeprobust) Using cached scikit_image-0.21.0-cp310-cp310-win_amd64.whl (22.8 MB) Collecting tensorboardX>=2.0 (from deeprobust) Using cached tensorboardX-2.6.1-py2.py3-none-any.whl (101 kB) Requirement already satisfied: tqdm>=3.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from deeprobust) (4.65.0) Collecting gensim<4.0,>=3.8 (from deeprobust) Using cached gensim-3.8.3.tar.gz (23.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [55 lines of output] running dist_info creating C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-xw8vksgb\gensim.egg-info writing C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-xw8vksgb\gensim.egg-info\PKG-INFO writing dependency_links to C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-xw8vksgb\gensim.egg-info\dependency_links.txt writing requirements to C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-xw8vksgb\gensim.egg-info\requires.txt writing top-level names to C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-xw8vksgb\gensim.egg-info\top_level.txt writing manifest file 'C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-xw8vksgb\gensim.egg-info\SOURCES.txt' Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in main() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main json_out['return_val'] = hook(hook_input['kwargs']) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 149, in prepare_metadata_for_build_wheel return hook(metadata_directory, configsettings) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\build_meta.py", line 380, in prepare_metadata_for_build_wheel self.runsetup() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup super(BuildMetaLegacyBackend, File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in runsetup exec(code, locals()) File "", line 367, in File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools__init__.py", line 107, in setup return distutils.core.setup(attrs) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51_\overlay\Lib\site-packages\setuptools_distutils\core.py", line 185, in setup return runcommands(dist) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools_distutils\core.py", line 201, in run_commands dist.runcommands() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools_distutils\dist.py", line 969, in run_commands self.runcommand(cmd) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\dist.py", line 1234, in run_command super().runcommand(command) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools_distutils\dist.py", line 988, in run_command cmdobj.run() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\command\dist_info.py", line 99, in run self.egginfo.run() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 314, in run self.findsources() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 322, in findsources mm.run() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 551, in run self.adddefaults() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 589, in add_defaults sdist.adddefaults(self) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools\command\sdist.py", line 104, in add_defaults super().adddefaults() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools_distutils\command\sdist.py", line 251, in add_defaults self._add_defaultsext() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools_distutils\command\sdist.py", line 335, in _add_defaults_ext build_ext = self.get_finalized_command('buildext') File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools_distutils\cmd.py", line 305, in get_finalized_command cmd_obj.ensurefinalized() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-mo48a51\overlay\Lib\site-packages\setuptools_distutils\cmd.py", line 111, in ensure_finalized self.finalize_options() File "", line 111, in finalize_options AttributeError: 'dict' object has no attribute '__NUMPY_SETUP__' [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

ChandlerBang commented 1 year ago

It seems that you are having a problem installing the gensim pacalakge.

One solution is to install gensim yourself on windows.

Then you need to modify the setup.py file by removing the 'gensim':

https://github.com/DSE-MSU/DeepRobust/blob/122588ed0eb5599206544d091c663ed89a3bbdb0/setup.py#L18-L33

First clone this repository, then modifysetup.py, and run python setup.py install.

primimazza commented 1 year ago

I tried to perform some solutions but the error persists C:\Users\Administrator>pip install gensim==3.8.3 Collecting gensim==3.8.3 Using cached gensim-3.8.3.tar.gz (23.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [55 lines of output] running dist_info creating C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-2ya76pcn\gensim.egg-info writing C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-2ya76pcn\gensim.egg-info\PKG-INFO writing dependency_links to C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-2ya76pcn\gensim.egg-info\dependency_links.txt writing requirements to C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-2ya76pcn\gensim.egg-info\requires.txt writing top-level names to C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-2ya76pcn\gensim.egg-info\top_level.txt writing manifest file 'C:\Users\Administrator\AppData\Local\Temp\pip-modern-metadata-2ya76pcn\gensim.egg-info\SOURCES.txt' Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in main() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main json_out['return_val'] = hook(hook_input['kwargs']) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 149, in prepare_metadata_for_build_wheel return hook(metadata_directory, config_settings) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\build_meta.py", line 380, in prepare_metadata_for_build_wheel self.run_setup() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup super(_BuildMetaLegacyBackend, File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in run_setup exec(code, locals()) File "", line 367, in File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools__init__.py", line 107, in setup return distutils.core.setup(attrs) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools_distutils\core.py", line 185, in setup return run_commands(dist) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools_distutils\core.py", line 201, in run_commands dist.run_commands() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools_distutils\dist.py", line 969, in run_commands self.run_command(cmd) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\dist.py", line 1234, in run_command super().run_command(command) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools_distutils\dist.py", line 988, in run_command cmd_obj.run() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\command\dist_info.py", line 99, in run self.egg_info.run() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 314, in run self.find_sources() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 322, in find_sources mm.run() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 551, in run self.add_defaults() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 589, in add_defaults sdist.add_defaults(self) File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools\command\sdist.py", line 104, in add_defaults super().add_defaults() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools_distutils\command\sdist.py", line 251, in add_defaults self._add_defaults_ext() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools_distutils\command\sdist.py", line 335, in _add_defaults_ext build_ext = self.get_finalized_command('build_ext') File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools_distutils\cmd.py", line 305, in get_finalized_command cmd_obj.ensure_finalized() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-vd0vpltf\overlay\Lib\site-packages\setuptools_distutils\cmd.py", line 111, in ensure_finalized self.finalize_options() File "", line 111, in finalize_options AttributeError: 'dict' object has no attribute '__NUMPY_SETUP__' [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

ChandlerBang commented 1 year ago

You may debug on how to install gensim in windows. Here is some answer from ChatGPT.

If the issue is hard to resolve, you can remove the file deeprobust/graph/defense/node_embedding.py which uses the gensim package and install the deeprobust package by "python setup.py install".

fsherry commented 1 year ago

@ChandlerBang Would you consider updating the version of gensim that is used in DeepRobust? This issue was fixed in gensim 4.3.0 (see https://github.com/RaRe-Technologies/gensim/releases/tag/4.3.0, with relevant issues https://github.com/RaRe-Technologies/gensim/issues/3225, https://github.com/RaRe-Technologies/gensim/issues/3362 and fix https://github.com/RaRe-Technologies/gensim/pull/3363).

They have also said that they will not fix it in the latest version of gensim that DeepRobust currently can use (3.8.3) since they are not supporting it anymore (https://github.com/RaRe-Technologies/gensim/pull/3386).

Since gensim is only used in one file in DeepRobust (https://github.com/DSE-MSU/DeepRobust/blob/d25d95b33724af9ab0385d5171c989f9b4ff2359/deeprobust/graph/defense/node_embedding.py) and the gensim API has only changed a little bit in the new version (https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4) I think it is very straightforward to achieve this. I'd be happy to prepare a PR for this if desired.

This fix would make it much easier to reliably share packages that depend on DeepRobust.

ChandlerBang commented 4 months ago

@fsherry Thanks so much for the suggestion, and I have updated the package dependencies!

I sincerely apologize for the late response as I missed this thread before.