[Django]-PythonAnywhere + virtualenv: "Could not find platform dependent libraries <exec_prefix>…"

5👍

There’s definitely something fishy going on if it can’t find module time – as far as I’m aware that module is actually built in to the Python binary itself so it’s not as if there’s a time.py or time.so file which could have been deleted. It looks as if either Python in your virtualenv has become broken somehow, or there’s something about the environment that’s messing it up.

Setting a dubious PYTHONHOME variable can cause Python all sorts of trouble as it can’t find necessary files, but I think in this case it’s the fact that the virtualenv has become broken. In fact, I just tried an old virtualenv on PythonAnywhere myself and got the same issue. It looks as if the symlinks that virtualenv creates have become broken as the result of an upgrade, possibly the recent upgrade from Debian to Ubuntu.

If at all possible I would simply re-create a new virtualenv and run things from there. In principle you could use pip to write a requirements file so you can create a new virtualenv with exactly the same versions of the code, but the problem is that you can’t run pip to create this file, QED. There’s probably a clever way to use the system Python to run pip and get the dependencies from your virtualenv, but it’s going to be tricky – it’s not designed to work that way.

Alternatively you could contact the PA devs – I know that some users did have problems with their virtualenvs around the time of the upgrade and they may have cunning scripts which can fix the problem. Even if you just build a new virtualenv and use it, I would contact them and make sure they know about this issue so they’re aware of it for future upgrades.

2👍

I had this happen to me this afternoon. I upgraded from Mint 14 to Mint 15, and it appears that the system python on the former is 2.7.3 and the latter uses 2.7.4. I fixed this by deleting my virtualenv (which used python 2.7.3) and then recreated it using python 2.7.4.

Check my quick screencast. In it, I show that:

  • the python environment is broken
  • recreating the python env makes it work

0👍

I get this error this day.Because i use virtualenv,and enter this,but ,my python script still contains this
#!/usr/bin/python2.6
delete this sentence will ok

Leave a comment