mindcurrent / djanky-django

Daniel's Janky Attempt at a Django RESTful API Server
0 stars 1 forks source link

Resolve Version Issues: Django vs Python #5

Open dpcunningham opened 4 years ago

dpcunningham commented 4 years ago

Working from the (rather stinky) tail-end (sniff, sniff) of Issue #4

Stack Exchange gives us some clues: Can't install Django 2.0 by pip

Oh, so there's a pip3 for python3? Well, thanks for mentioning that to folks trying to get spun up on your shizzle without getting wrapped around the flagpole!

JFC! Do you want people to use Djaogo, or not? Do you want them to get screwed in production by version compatibility issues? This is what I effing hate about Python!

Other than that, of course, I love Python.

Let's explore this fascinating issue of version compatibility...

So, installing Django does not auto-magically get you Django?

dpc@LT3-Insp17-2017:~$ python -m django --version
1.11.24

dpc@LT3-Insp17-2017:~$ python
Python 2.7.15+ (default, Jul  9 2019, 16:51:35) 
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> django.VERSION
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'django' is not defined
>>> print(django.get_version())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'django' is not defined
>>> ^d

dpc@LT3-Insp17-2017:~$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> django.VERSION
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'django' is not defined
>>> print(django.get_version())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'django' is not defined
>>> ^d

How quaint. I guess my expectations are naive.
Or maybe this is sophis-tuh-mih-cated, because you only pull in what you want at run time? I could accept that argument.

OK, I'll axe for it, then:

dpc@LT3-Insp17-2017:~$ python -m django --version
1.11.24

dpc@LT3-Insp17-2017:~$ python
Python 2.7.15+ (default, Jul  9 2019, 16:51:35) 
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 11, 24, u'final', 0)
>>> print(django.get_version())
1.11.24
>>> ^d

dpc@LT3-Insp17-2017:~$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
>>> ^d

Great. So we got squat for Python v3.x.

Let's fix this:

dpc@LT3-Insp17-2017:~$ pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
dpc@LT3-Insp17-2017:~$ pip3 --version

Command 'pip3' not found, but can be installed with:
sudo apt install python3-pip

dpc@LT3-Insp17-2017:~$ sudo apt install python3-pip
dpc@LT3-Insp17-2017:~$ sudo apt update

dpc@LT3-Insp17-2017:~$ pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
dpc@LT3-Insp17-2017:~$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Stepping back through issue #3:

dpc@LT3-Insp17-2017:~$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

dpc@LT3-Insp17-2017:~$ pip3 install --user virtualenv
Collecting virtualenv
  Using cached https://files.pythonhosted.org/packages/8b/12/8d4f45b8962b03ac9efefe5ed5053f6b29334d83e438b4fe379d21c0cb8e/virtualenv-16.7.5-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-16.7.5

And let's repeat step #4:

dpc@LT3-Insp17-2017:~$ pip3 install Django
Collecting Django
  Downloading https://files.pythonhosted.org/packages/b2/79/df0ffea7bf1e02c073c2633702c90f4384645c40a1dd09a308e02ef0c817/Django-2.2.6-py3-none-any.whl (7.5MB)
    100% |████████████████████████████████| 7.5MB 170kB/s 
Collecting sqlparse (from Django)
  Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Collecting pytz (from Django)
  Using cached https://files.pythonhosted.org/packages/87/76/46d697698a143e05f77bec5a526bf4e56a0be61d63425b68f4ba553b51f2/pytz-2019.2-py2.py3-none-any.whl
Installing collected packages: sqlparse, pytz, Django
Successfully installed Django-2.2.6 pytz-2019.2 sqlparse-0.3.0

And... let's see what we gots:

dpc@LT3-Insp17-2017:~$ python -m django --version
1.11.24
dpc@LT3-Insp17-2017:~$ python
Python 2.7.15+ (default, Jul  9 2019, 16:51:35) 
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 11, 24, u'final', 0)
>>> print(django.get_version())
1.11.24
>>> ^d

dpc@LT3-Insp17-2017:~$ python3 -m django --version
2.2.6
dpc@LT3-Insp17-2017:~$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(2, 2, 6, 'final', 0)
>>> print(django.get_version())
2.2.6
>>> ^d

OK. I can live with this.