conan-extensions icon indicating copy to clipboard operation
conan-extensions copied to clipboard

cannot import name 'api_request' from 'utils'

Open agclqq opened this issue 1 year ago • 2 comments

When I install the following command, the following prompt appears, how to solve it, thanks!

❯ conan config install https://github.com/conan-io/conan-extensions.git
Trying to clone repo: https://github.com/conan-io/conan-extensions.git
Repo cloned!
Copying file runtime_zip_deploy.py to /Users/robin/.conan2/extensions/deployers
Copying file licenses.py to /Users/robin/.conan2/extensions/deployers
Copying file cmd_cyclonedx.py to /Users/robin/.conan2/extensions/commands/sbom
Copying file readme_build_info.md to /Users/robin/.conan2/extensions/commands/art
Copying file cmd_property.py to /Users/robin/.conan2/extensions/commands/art
Copying file utils.py to /Users/robin/.conan2/extensions/commands/art
Copying file cmd_server.py to /Users/robin/.conan2/extensions/commands/art
Copying file readme_server.md to /Users/robin/.conan2/extensions/commands/art
Copying file readme_property.md to /Users/robin/.conan2/extensions/commands/art
Copying file cmd_build_info.py to /Users/robin/.conan2/extensions/commands/art
Copying file cmd_bump_deps.py to /Users/robin/.conan2/extensions/commands/recipe
Copying file cmd_convert_txt.py to /Users/robin/.conan2/extensions/commands/migrate
Copying file cmd_export_all_versions.py to /Users/robin/.conan2/extensions/commands/cci
Copying file cmd_upgrade_qt_recipe.py to /Users/robin/.conan2/extensions/commands/cci
Copying file cmd_list_v2_ready.py to /Users/robin/.conan2/extensions/commands/cci

❯ conan art:server --help
ERROR: Error loading custom command art.cmd_build_info: cannot import name 'api_request' from 'utils' (/Users/robin/miniconda3/lib/python3.11/site-packages/utils/__init__.py)
ERROR: Error loading custom command art.cmd_property: cannot import name 'api_request' from 'utils' (/Users/robin/miniconda3/lib/python3.11/site-packages/utils/__init__.py)
ERROR: Error loading custom command art.cmd_server: cannot import name 'api_request' from 'utils' (/Users/robin/miniconda3/lib/python3.11/site-packages/utils/__init__.py)
'art:server' is not a Conan command. See 'conan --help'.

ERROR: Unknown command 'art:server'
ERROR: Error loading custom command art.cmd_build_info: cannot import name 'api_request' from 'utils'

agclqq avatar Nov 02 '23 07:11 agclqq

Hi @agclqq

Thanks for your report. I am not sure why it could be failing in your case. Could you please remove the .conan2/extensions folder and try a fresh conan config install and try again? It seems that for some reason the utils file wouldn't be up to date with the latest https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/art/utils.py, but I don't know why (maybe you can check the file in your .conan2/extensions folder and verify if it contains the api_request() method before removing it, to validate)

memsharded avatar Nov 02 '23 09:11 memsharded

Hi @agclqq,

Maybe the issue comes because Python is doing the import of a "utils" package installed in your environment. Could you check that?

This is something we would like to address to ensure the commands work for the majority of users. Thank you!

danimtb avatar Jan 03 '24 13:01 danimtb

Closing this issue due to no activity. Please reopen if the problem persists or open a new issue to report any other one. Thanks!

danimtb avatar May 24 '24 07:05 danimtb