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 · 25 comments

Comments

Projects
None yet
@matinde

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

This comment has been minimized.

Show comment
Hide comment
@varunbalupuri

varunbalupuri Apr 7, 2018

Upgrading virtualenv fixed this for me.

sudo pip install virtualenv --upgrade

Please try that and see if the problem is fixed.

varunbalupuri commented Apr 7, 2018

Upgrading virtualenv fixed this for me.

sudo pip install virtualenv --upgrade

Please try that and see if the problem is fixed.

@matinde

This comment has been minimized.

Show comment
Hide comment
@matinde

matinde Apr 8, 2018

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

matinde commented Apr 8, 2018

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

@paulclarkaranz

This comment has been minimized.

Show comment
Hide comment
@paulclarkaranz

paulclarkaranz Apr 8, 2018

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@disambiguator

disambiguator Apr 9, 2018

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

disambiguator commented Apr 9, 2018

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

This comment has been minimized.

Show comment
Hide comment
@scoates

scoates Apr 9, 2018

Collaborator

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

Collaborator

scoates commented Apr 9, 2018

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

@scoates scoates closed this Apr 9, 2018

@neotheicebird

This comment has been minimized.

Show comment
Hide comment
@neotheicebird

neotheicebird Apr 15, 2018

AttributeError: 'pip' has no attribute 'get_installed_distributions'

For pip == 10.0.0

You can downgrade pip to >= 9.0.0 to fix this

neotheicebird commented Apr 15, 2018

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

This comment has been minimized.

Show comment
Hide comment
@oxbits

oxbits 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

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

This comment has been minimized.

Show comment
Hide comment
@wobeng

wobeng Apr 18, 2018

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@paulclarkaranz

paulclarkaranz Apr 18, 2018

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@shivampaw

shivampaw Apr 25, 2018

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

shivampaw commented Apr 25, 2018

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

This comment has been minimized.

Show comment
Hide comment
@disambiguator

disambiguator Apr 25, 2018

@shivampaw sudo pip3 install virtualenv --upgrade

disambiguator commented Apr 25, 2018

@shivampaw sudo pip3 install virtualenv --upgrade

@shivampaw

This comment has been minimized.

Show comment
Hide comment
@shivampaw

shivampaw Apr 25, 2018

nvm, turns out rebooting does fix problems...

shivampaw commented Apr 25, 2018

nvm, turns out rebooting does fix problems...

@naamancampbell

This comment has been minimized.

Show comment
Hide comment
@naamancampbell

naamancampbell Apr 27, 2018

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

naamancampbell commented Apr 27, 2018

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

This comment has been minimized.

Show comment
Hide comment
@NathanLawrence

NathanLawrence May 9, 2018

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.

NathanLawrence commented May 9, 2018

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

This comment has been minimized.

Show comment
Hide comment
@scoates

scoates May 9, 2018

Collaborator

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

#1478 + #1481

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

This comment has been minimized.

Show comment
Hide comment
@jasweet

jasweet 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.

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

This comment has been minimized.

Show comment
Hide comment
@Shaun1

Shaun1 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.

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

This comment has been minimized.

Show comment
Hide comment
@jasweet

jasweet 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.

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

This comment has been minimized.

Show comment
Hide comment
@raveenb

raveenb May 20, 2018

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

raveenb commented May 20, 2018

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

@WonderMr

This comment has been minimized.

Show comment
Hide comment
@WonderMr

WonderMr May 25, 2018

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

WonderMr commented May 25, 2018

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

This comment has been minimized.

Show comment
Hide comment
@MoBattah

MoBattah May 31, 2018

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

MoBattah commented May 31, 2018

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

@NathanLawrence

This comment has been minimized.

Show comment
Hide comment
@NathanLawrence

NathanLawrence Jun 7, 2018

@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?

NathanLawrence commented Jun 7, 2018

@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

This comment has been minimized.

Show comment
Hide comment
@fergyfresh

fergyfresh 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'

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

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

This comment has been minimized.

Show comment
Hide comment
@ufmayer

ufmayer 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

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

This comment has been minimized.

Show comment
Hide comment
@nabaz

nabaz Oct 3, 2018

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

nabaz commented Oct 3, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment