[Tutor] I think I've broken my Python

Mats Wichmann mats at wichmann.us
Mon Nov 12 10:29:40 EST 2018


On 11/12/18 4:45 AM, Matthew Ngaha wrote:
> I haven't coded in about 3 years and I used to use Python3.4 on
> openSUSE13.1. I had a virtual environment with this Python for a
> development Django website. Before I stopped coding, I upgraded to
> Python3.5, but everything still worked if I remember correctly. But
> now I'm back to coding I tried to load up my Django website but I get
> the error:
> Traceback (most recent call last):
>   File "manage.py", line 8, in <module>
>     from django.core.management import execute_from_command_line
> ImportError: No module named django.core.management
> 
> What happens is Django's manage.py can't be found so the line:
> "from django.core.management import execute_from_command_line"
> throws the error. In the virtual environment when I type python in the
> command line, it opens Python2.7 and when I type Python3, it opens
> Python3.5. So it seems my Python3.4 is lost. I thought the virtual
> environment only loaded up the Python version it was installed for, in
> my case Python3.4 when I type python or python3 in the command line,
> had I known this wasn't the case I would have never upgraded Python.
> Is there anything I can do?

Reconstruct the virtualenv you want maybe? Their whole concept is that
they're cheap and easy and can just be thrown away.  Of course, you then
have to remember what you did to create it in order to make a new one...

Virtualenv *can* make a full copy of the Python environment you are
building it from, but does not by default - it uses links to save space
if the platform is okay with that.  That does mean that if the original
goes away due to version upgrade, you're likely to be left with an
unusable virtualenv (see the --always-copy argument to virtualenv).

Since you're on a Linux platform, use "which" to see how the names you
are typing are resolving

which python
which python3

Usually if the virtualenv has been broken by external factors, it won't
even activate. Are you sure you remembered to try to activate it?



More information about the Tutor mailing list