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

AttributeError: 'module' has no attribute 'get_installed_distributions' #1471

Closed
matinde opened this issue Apr 7, 2018 · 28 comments
Closed
Labels

Comments

@matinde
Copy link

matinde commented Apr 7, 2018

Context

When deploying a project with "zappa deploy [project-name]" I get the error: AttributeError: 'module' has no attribute 'get_installed_distributions'

I honestly do not know what is wrong or what I am missing. Any help please provide simple step by step instructions to solve this.
zappa error

@varunbalupuri
Copy link

Upgrading virtualenv fixed this for me.

sudo pip install virtualenv --upgrade

Please try that and see if the problem is fixed.

@matinde
Copy link
Author

matinde commented Apr 8, 2018

Thanks, but I did upgrade virtualenv but it didn't work. I still get the error message.

@paulclarkaranz
Copy link
Contributor

paulclarkaranz commented Apr 8, 2018

You probably have a newer pip, they made changes to their public api top level functions recently. Try downgrading with pip install pip==9.0.1 or to 8.1.2. pypa/pip#5154

@disambiguator
Copy link

I also got this to work by running sudo pip3 install virtualenv --upgrade. Thank you for your response @varunbalupuri !

@scoates scoates added the non-bug label Apr 9, 2018
@scoates
Copy link
Collaborator

scoates commented Apr 9, 2018

Closing. Comment and we'll reopen if it's a Zappa problem.

@scoates scoates closed this as completed Apr 9, 2018
@neotheicebird
Copy link

AttributeError: 'pip' has no attribute 'get_installed_distributions'

For pip == 10.0.0

You can downgrade pip to >= 9.0.0 to fix this

@oxbits
Copy link

oxbits commented Apr 15, 2018

Thank you @neotheicebird! I downgraded to 9.0.3 and it fixed the issue for me:
$ pip install pip==9.0.3

@wobeng
Copy link
Contributor

wobeng commented Apr 18, 2018

@scoates how come you don't consider this as a Zappa issue? adjusting to pip is better than downgrading to Zappa

@paulclarkaranz
Copy link
Contributor

paulclarkaranz commented Apr 18, 2018

There are already two open issues about adapting to pip's new api (aka subprocess): #1478 #1446
Also a PR #1481, although I don't think that is the fix that the pip devs would recommend.

@shivampaw
Copy link

I'm running into this issue. I tried downgrading pip and can confirm it is done because pip --version returns 9.0.3 but i still get the same error from zappa

@disambiguator
Copy link

@shivampaw sudo pip3 install virtualenv --upgrade

@shivampaw
Copy link

nvm, turns out rebooting does fix problems...

@naamancampbell
Copy link

Installing pip==9.0.3 after activating the virtualenv works for me:

pip install virtualenv
virtualenv venv
. ./venv/bin/activate
pip install pip==9.0.3

@NathanLawrence
Copy link

I know this issue is closed, but this is obviously still ongoing, and I'd love if we could find a way to patch it up. Anyone clear on the mechanics of what's going wrong here? I'm happy to get my hands dirty, but only if I know what I'm doing.

@scoates
Copy link
Collaborator

scoates commented May 9, 2018

My comment above was indeed in error, but the root of this problem is the pip changes, I believe, now.

#1478 + #1481

@jasweet
Copy link

jasweet commented May 13, 2018

Hello all.

The prob is def pip. Broken in 10.x.

However, depending on your environment, you may need to downgrade pip or pip3. For my fedora box it was pip and my windows machine was pip3. Just depends which interpreter you're using for the problem file/package.

@Shaun1
Copy link

Shaun1 commented May 14, 2018

Downgrading to pip 9.0.3 (both globally and in virutualenv) worked for me too. But this sounds like a Zappa issue, not a pip issue.

@jasweet
Copy link

jasweet commented May 15, 2018

True. It’s that pip updated location/structure of some internal resources. Other libraries that leverage resources internal to pip can become broken when pip makes changes.

@raveenb
Copy link

raveenb commented May 20, 2018

I too have had this issue, downgrading pip in the virtualenv resolved this

@WonderMr
Copy link

For pip 10 use from pip._internal.utils.misc import get_installed_distributions

kontrollanten added a commit to hitta-skyddsrum/services that referenced this issue May 30, 2018
kontrollanten added a commit to hitta-skyddsrum/services that referenced this issue May 30, 2018
kontrollanten added a commit to hitta-skyddsrum/services that referenced this issue May 31, 2018
@MoBattah
Copy link

Breaks Zappa. None of the above suggestions worked for me.

@NathanLawrence
Copy link

@MoBattah Exact same issue, yet you couldn't get it to find the APIs even when you're running the old version? Mind posting up prints of pip -V inside and outside your virtualenvs so we can troubleshoot?

@fergyfresh
Copy link

fergyfresh commented Jun 13, 2018

This 100% doesn't work with pip==10.0.1 and definitely does work with pip==9.0[1|2|3]. My workaround is pip freeze-ing after installing pip9 because my base tooling is setup for 10.

==============

Traceback (most recent call last):
  File "/home/ferg/geemusic/.venv/lib/python3.6/site-packages/zappa/cli.py", line 2610, in handle
    sys.exit(cli.handle())
  File "/home/ferg/geemusic/.venv/lib/python3.6/site-packages/zappa/cli.py", line 505, in handle
    self.dispatch_command(self.command, stage)
  File "/home/ferg/geemusic/.venv/lib/python3.6/site-packages/zappa/cli.py", line 549, in dispatch_command
    self.update(self.vargs['zip'], self.vargs['no_upload'])
  File "/home/ferg/geemusic/.venv/lib/python3.6/site-packages/zappa/cli.py", line 877, in update
    self.create_package()
  File "/home/ferg/geemusic/.venv/lib/python3.6/site-packages/zappa/cli.py", line 2171, in create_package
    disable_progress=self.disable_progress
  File "/home/ferg/geemusic/.venv/lib/python3.6/site-packages/zappa/core.py", line 595, in create_lambda_zip
    installed_packages = self.get_installed_packages(site_packages, site_packages_64)
  File "/home/ferg/geemusic/.venv/lib/python3.6/site-packages/zappa/core.py", line 751, in get_installed_packages
    pip.get_installed_distributions()
AttributeError: module 'pip' has no attribute 'get_installed_distributions'

==============

@ufmayer
Copy link

ufmayer commented Aug 13, 2018

Following WonderMr's post, this worked for me:

if pip.__version__ >= "10.0.0":
    from pip._internal.utils.misc import get_installed_distributions
else:
    from pip import get_installed_distributions

@nabaz
Copy link

nabaz commented Oct 3, 2018

downgrade pip and remove slim-handler if you have that option set also

@jpza
Copy link

jpza commented Jan 2, 2019

Downgrading pip should not be a fix here since the suggested downgrade is 10 versions behind the latest

@ryanjdillon
Copy link

ryanjdillon commented Jan 24, 2019

I just encountered this as well. According to this issue, this should be updated to use pkg_resources.working_set.

@johnyoonh
Copy link

For me it was setting the runtime properly in zappa_settings.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests