2

I'm trying to set up an EC2 instance with django but I'm having issues installing anything. I ran sudo apt-get update and upgrade -y. But when I try to run pip which it claims is installed I get this:

ubuntu@ip-172-31-62-51:/home$ pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

When I try sudo apt-get upgrade -y I get this:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
  linux-headers-virtual linux-image-virtual linux-virtual
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python-pip (1.0-1build1) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 36, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser
dpkg: error processing python-pip (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-twisted-names (11.1.0-1) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 36, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser
dpkg: error processing python-twisted-names (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 python-pip
 python-twisted-names
E: Sub-process /usr/bin/dpkg returned an error code (1)

I actually get this error anything I try to use apt-get for anything.

Also anytime I try to actually use pip I get this:

ubuntu@ip-172-31-62-51:/home$ sudo pip install virtualenv
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

When I try to use apt-add-repository ppa:chris-lea/nodejs (since sudo apt-get install nodejs doesn't work) I get:

ubuntu@ip-172-31-62-51:/home$ sudo apt-add-repository ppa:chris-lea/nodejs
  File "/usr/bin/apt-add-repository", line 37
    print _("The %s named '%s' has no PPA named '%s'"
          ^
SyntaxError: invalid syntax

I had it work before, but I was having the same problems with pip and such, I tried a fresh instance using Ubuntu Server 12 rather than 14, but I'm having same problems. Although on 14 I couldnt get nginx to install and on 12 I could. I was able to install ruby, as well as ruby gems like sass/scss. I got node installed without the new repo. npm won't install via apt-get though, same error as before. Why is this happening? I can't even get virtualenv installed, I can't use this for development as it doesn't even have all the items I need for the production product. Is ubuntu 12 the problem (although 14 had issues too). Should I switch to another AMI?

Any idea why things aren't working right?

Thanks

EDIT: I get the same error if i try to remove pip with apt.

Mikko Ohtamaa
  • 69,174
  • 40
  • 208
  • 346
shenk
  • 2,508
  • 6
  • 30
  • 75
  • 1
    Do you do anything funny like upgrading Python on the server or install any libraries using `sudo pip`? On fresh EC2 Ubuntu install this definitely is not happening, so maybe we have different concept of fresh or different base image. – Mikko Ohtamaa Apr 22 '15 at 11:26
  • 1
    Have you tried http://stackoverflow.com/questions/7446187/no-module-named-pkg-resources ? – aumo Apr 22 '15 at 11:32
  • I tried, still didn't work – shenk Apr 22 '15 at 12:48
  • And yes, it was a fresh instance, I didn't do anything but install ruby, gunicorn, and nginx – shenk Apr 22 '15 at 12:48
  • I managed to get it working by just starting a new instance. Still not what was the actual problem. I tried a premade AMI and had the same issues, and then tried another instance from scratch and it began to work. Confusing. – shenk Apr 28 '15 at 08:10

2 Answers2

0

Switching to a fresh EC2 instance fix the problem.

shenk
  • 2,508
  • 6
  • 30
  • 75
0

use 'sudo pip install xxx',it fixed my problem.

Jarvis
  • 1