Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ImportError: cannot import name 'packages_distributions' from 'importlib_metadata' #105

Closed
sabotagebeats opened this issue Jul 23, 2021 · 4 comments
Labels
category: bug Something isn't working

Comments

@sabotagebeats
Copy link
Contributor

Environment information

ape will not run after install

$ ape --version
# ...copy and paste result of above command here...

$ ape plugins list
# ...copy and paste result of above command here...
  • Python Version: 3.8.10
  • OS: ubuntu 20.04LTS server linux

What went wrong?

$ ape --version
Traceback (most recent call last):
  File "/home/sabotage/.local/bin/ape", line 5, in <module>
    from ape._cli import cli
  File "/home/sabotage/.local/lib/python3.8/site-packages/ape/__init__.py", line 5, in <module>
    from .api.contracts import _Contract
  File "/home/sabotage/.local/lib/python3.8/site-packages/ape/api/__init__.py", line 1, in <module>
    from .accounts import AccountAPI, AccountContainerAPI
  File "/home/sabotage/.local/lib/python3.8/site-packages/ape/api/accounts.py", line 7, in <module>
    from ape.types import ContractType
  File "/home/sabotage/.local/lib/python3.8/site-packages/ape/types/__init__.py", line 1, in <module>
    from .contract import ABI, Bytecode, Checksum, Compiler, ContractType, Source
  File "/home/sabotage/.local/lib/python3.8/site-packages/ape/types/contract.py", line 5, in <module>
    from ape.utils import compute_checksum
  File "/home/sabotage/.local/lib/python3.8/site-packages/ape/utils.py", line 12, in <module>
    from importlib_metadata import PackageNotFoundError, packages_distributions, version
ImportError: cannot import name 'packages_distributions' from 'importlib_metadata' (/usr/lib/python3/dist-packages/importlib_metadata/__init__.py)

How can it be fixed?

I'm not sure if this is a path error or what

@sabotagebeats sabotagebeats added the category: bug Something isn't working label Jul 23, 2021
@fubuloubu
Copy link
Member

Are you running this with Python 3.6 or 3.7?

@sabotagebeats
Copy link
Contributor Author

running this with python 3.8. I noticed I got this error when I'm in the wrong pyenv before installing ape. so i tried this:

~/ape/ape$ pyenv virtualenv freshape
~/ape/ape$ pyenv activate freshape
~/ape/ape$ pip install -e .
[truncated]
Installing collected packages: eth-ape
  Attempting uninstall: eth-ape
    Found existing installation: eth-ape 0.1.0a16
    Uninstalling eth-ape-0.1.0a16:
      Successfully uninstalled eth-ape-0.1.0a16
  Running setup.py develop for eth-ape
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sabotage/ape/ape/setup.py'"'"'; __file__='"'"'/home/sabotage/ape/ape/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
         cwd: /home/sabotage/ape/ape/
    Complete output (18 lines):
    running develop
    WARNING: The user site-packages directory is disabled.
    error: can't create or remove files in install directory
    
    The following error occurred while trying to add or remove files in the
    installation directory:
    
        [Errno 2] No such file or directory: '/usr/lib/python3.8/site-packages/test-easy-install-99759.write-test'
    
    The installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:
    
        /usr/lib/python3.8/site-packages/
    
    This directory does not currently exist.  Please create it and try again, or
    choose a different installation directory (using the -d or --install-dir
    option).
    
    ----------------------------------------
  Rolling back uninstall of eth-ape
[truncated]
ERROR: Command errored out with exit status 1: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sabotage/ape/ape/setup.py'"'"'; __file__='"'"'/home/sabotage/ape/ape/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.

@fubuloubu
Copy link
Member

running this with python 3.8. I noticed I got this error when I'm in the wrong pyenv before installing ape. so i tried this:

This looks like pyenv isn't doing the job of segregating by virtualenv correctly... which is strange. Let's work through this together.

@sabotagebeats
Copy link
Contributor Author

this was an issue with pyenv, and the appropriate pyenv was not added to the ~/.bashrc

# So pyenv gets recognized
export PATH="$PATH:$HOME/.pyenv/bin"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

then run source ~/.bashrc

after this my pyenv was installed in the wrong place

$ pyenv virtualenvs
  apeworx (created from /usr)

so i deleted my pyenv and recreated it and it looks right

$ pyenv virtualenv-delete apeworx
$ pyenv virtualenv apeworx && pyenv activate apeworx
$ which python
/home/sabotage/.pyenv/shims/python
$ pyenv virtualenvs
  apeworx (created from /home/sabotage/.pyenv/versions/3.8.10)

once I did that my eth-ape was still in the wrong place

$ which ape
/usr/local/bin/ape
$ sudo rm /usr/local/bin/ape
$ pip install eth-ape
Successfully installed eth-ape-0.1.0a17
$ which ape
/home/sabotage/.pyenv/shims/ape
$ ape --version
0.1.0a17

ok great now this is looking good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants