9

I've seen a couple of fixes for this, but none have worked for me, but I gather that its my virtualenvs that got broken. I just upgraded to 14.04 from 12.04, and now all my pyramid applications no longer work.

When I run ../bin/pserve development.ini, I get the following error:
ImportError: No module named _ctypes

When I run ../bin/python setup.py develop, (also when I try run pshell) I get:
ImportError: No module named _io

I've fixed one project (each pyramid app is in a separate virtualenv) by first removing the old project folder, then reinstalling the virtualenv instance and then copying my scripts back into it. But this is time consuming, and I have several projects.

Is there a quick fix for this?
I've seen removing duplicates of python and simple reinstall of virtualenv, but removing duplicates is not a good option, and the second solution didn't work for me. But maybe I did something wrong there.

I really think that there should be a quick fix for this. Surely reinstalling all virtualenvs cannot be the only solution?

Community
  • 1
  • 1
Roman
  • 8,826
  • 10
  • 63
  • 103
  • It's your default python version that is installed which differs. On Ubuntu 12.04 it was python 2.7.3 and on Ubuntu 14.04 it is 2.7.6 , but this shouldn't break your virtualenvs. – flazzarini Aug 22 '14 at 08:26
  • Need help or already fixed it? – Sascha Gottfried Sep 02 '14 at 15:14
  • Yes Please! I never found a solution beyond just reinstalling everything. – Roman Sep 03 '14 at 12:45
  • possible duplicate of [ImportError: No module named \_io in ubuntu 14.04](http://stackoverflow.com/questions/23176697/importerror-no-module-named-io-in-ubuntu-14-04) – Bryce Sep 18 '14 at 04:16

2 Answers2

4

You can simply do

cp /usr/bin/python2 /path/to/my-virtualenv/bin/python2

or

cp /usr/bin/python3 /path/to/my-virtualenv/bin/python3

(Don't need to make a new virtualenv.)

aiai
  • 525
  • 4
  • 11
1

A quick fix that works is to create a new virtualenv and copy its bin/python to the broken virtualenvs. Five simple steps:

  1. mkvirtualenv lero
  2. cd ~/.virtualenvs
  3. for d in */; do cp lero/bin/python $d/bin/python; done
  4. deactivate
  5. rmvirtualenv lero
Pedro Werneck
  • 40,902
  • 7
  • 64
  • 85
  • Thanks this helped me. Also needed: sudo easy_install -U pip and sudo easy_install -U Distribute. Then I did a pip freeze and took the version of virtualbox shown and fixed it in two places here: /usr/local/bin/virtualenv. – joeButler Mar 19 '15 at 15:05