[Tutor] I think I've broken my Python
Mats Wichmann
mats at wichmann.us
Mon Nov 12 12:50:33 EST 2018
On 11/12/18 10:07 AM, Matthew Ngaha wrote:
> On Mon, Nov 12, 2018 at 3:31 PM Mats Wichmann <mats at wichmann.us> wrote:
>>
>> 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...
>
> It's been 3 years, I'm clueless as to how I created it. Also I'm a
> noob when it comes to Linux which makes this even more confusing for
> me. The 3 years I've been absent from Programming I went back to
> Windows.
>
>> Since you're on a Linux platform, use "which" to see how the names you
>> are typing are resolving
>>
>> which python
>> which python3
>
> The "command" gives this output:
>
> (website) matthew at linux-oq68:~/Documents/mywork/web/website/blogsite>
> which python
> /usr/bin/python
> (website) matthew at linux-oq68:~/Documents/mywork/web/website/blogsite>
> which python3
> /usr/bin/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?
>>
> Yep, I double checked to make sure I remembered to try to activate it.
>
it's possible there was never a virtualenv involved... on a Linux system
you'd normally install the distribution package for django, instead of
installing bits in a virtualenv. The distro package contains a template
manage.py. Which, on a current Fedora, contains wording suggesting maybe
a virtualenv wasn't started - but the real message is that it couldn't
find necessary Django pieces in the python environment (this is
consistent with your original message, suggesting it found and is
running manage, but other things are missing).
Here's the interesting part of the content of that template for those
who might have more ideas:
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name
}}.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
More information about the Tutor
mailing list