Difference between revisions of "Python and Django"

From HaFrWiki
Jump to: navigation, search
m (See also)
m (See also)
 
Line 129: Line 129:
 
== See also ==
 
== See also ==
 
<span class="editsection">[[#content|top]]</span>
 
<span class="editsection">[[#content|top]]</span>
* [https://docs.djangoproject.com/en/2.0/topics/install/#installing-official-release Djangoproject.com], Installting Django
+
* [https://docs.djangoproject.com/en/2.0/topics/install/#installing-official-release Djangoproject.com], Installing Django
* [https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/development_environment Developer Mozilla], Django installation.
+
* [https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/development_environment Developer Mozilla], Setting up a Django development environment by Mozilla
 +
* [https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/modwsgi Djangoproject.com], Apache Server the mod_wsgi configuration.
  
 
== Reference ==
 
== Reference ==

Latest revision as of 13:40, 24 December 2017

Introduction

Mac OSX

Standard Python version 2.7.10 is installed on Mac OSX High Sierra and under MAMP. This version is located in:

  • /Application/MAMP/Library/bin/python
  • /usr/bin/python

Official this version is deprecated and is out-of-service from 2020. A good reason to upgrade [1]. The installer will create a directory:

  • /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
  • /usr/local/bin/python3.6

Python 2 installation

Python 2 is part of the software stack of the MAMP-installation.

The symbolic links in the Application MAMP bin directory (/Applications/MAMP/Library/bin): <syntaxhighlight lang="bash" line start="1"> $ la python* lrwxr-xr-x 1 frielink1 admin 7B Dec 23 20:01 python -> python2 lrwxr-xr-x 1 frielink1 admin 14B Mar 8 2016 python-config -> python2-config lrwxr-xr-x 1 frielink1 admin 9B Mar 8 2016 python2 -> python2.7 lrwxr-xr-x 1 frielink1 admin 16B Mar 8 2016 python2-config -> python2.7-config -rwxrwxr-x 1 frielink1 admin 2.0M Jul 6 2015 python2.7 -rwxrwxr-x 1 frielink1 admin 1.7K Jul 6 2015 python2.7-config </syntaxhighlight>

  • The 2st and 4rd' symbolic link make the python command point to python2.7 on the 6th line.
  • The 3nd and 5th symbolic link make the python-config command point to the python2.7-config on the 7th line.

python 3.7 installation

This version has been installed by the Mac user. It has the following symbolic links (/usr/local/bin): <syntaxhighlight lang="bash" line start="1"> $ la python* lrwxr-xr-x 1 root wheel 69B Dec 23 19:11 python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3 lrwxr-xr-x 1 root wheel 72B Dec 23 19:11 python3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3-32 lrwxr-xr-x 1 root wheel 76B Dec 23 19:11 python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3-config lrwxr-xr-x 1 root wheel 71B Dec 23 19:11 python3.6 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 lrwxr-xr-x 1 root wheel 74B Dec 23 19:11 python3.6-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-32 lrwxr-xr-x 1 root wheel 78B Dec 23 19:11 python3.6-config -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-config lrwxr-xr-x 1 root wheel 72B Dec 23 19:11 python3.6m -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m lrwxr-xr-x 1 root wheel 79B Dec 23 19:11 python3.6m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m-config </syntaxhighlight> There are 3 different Python version of 3.6 installed:

  • Python 3
  • Python 3.6
  • Python 3,6m

Migrate 2.7 to 3.6

First remove the python and python-config from the MAMP bin (/Applications/MAMP/Library/bin): <syntaxhighlight lang="bash" line start="1"> $ pwd /Applications/MAMP/Library/bin

$ mv python python_ $ mw python-config python-config_ </syntaxhighlight>

<syntaxhighlight lang="bash" line start="1"> $ pwd /usr/local/bin

$ ln -s /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 python lrwxr-xr-x 1 frielink1 admin 63B Dec 23 19:52 python -> /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6

$ ln -s /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-config python-config

  1. Resulting in:

la python* lrwxr-xr-x 1 frielink1 admin 63B Dec 23 19:52 python -> /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 lrwxr-xr-x 1 frielink1 admin 70B Dec 24 10:41 python-config -> /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-config lrwxr-xr-x 1 root wheel 69B Dec 23 19:11 python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3 lrwxr-xr-x 1 root wheel 72B Dec 23 19:11 python3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3-32 lrwxr-xr-x 1 root wheel 76B Dec 23 19:11 python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3-config lrwxr-xr-x 1 root wheel 71B Mar 8 2016 python3.5 -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 lrwxr-xr-x 1 root wheel 74B Mar 8 2016 python3.5-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5-32 lrwxr-xr-x 1 root wheel 78B Mar 8 2016 python3.5-config -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5-config lrwxr-xr-x 1 root wheel 72B Mar 8 2016 python3.5m -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5m lrwxr-xr-x 1 root wheel 79B Mar 8 2016 python3.5m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5m-config lrwxr-xr-x 1 root wheel 71B Dec 23 19:11 python3.6 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 lrwxr-xr-x 1 root wheel 74B Dec 23 19:11 python3.6-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-32 lrwxr-xr-x 1 root wheel 78B Dec 23 19:11 python3.6-config -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-config lrwxr-xr-x 1 root wheel 72B Dec 23 19:11 python3.6m -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m lrwxr-xr-x 1 root wheel 79B Dec 23 19:11 python3.6m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m-config </syntaxhighlight>

PIP

Make sure you have the right version of pip, see the /usr/local/bin: <syntaxhighlight lang="bash" line start="1"> $ la pip* lrwxr-xr-x 1 frielink1 admin 4B Dec 24 10:49 pip -> pip3 -rwxr-xr-x 1 root admin 283B Dec 23 13:31 pip2 -rwxr-xr-x 1 root admin 287B Dec 23 13:31 pip2.7 lrwxrwxr-x 1 root admin 66B Dec 23 19:11 pip3 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 lrwxrwxr-x 1 root admin 68B Dec 23 19:11 pip3.6 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/pip3.6 -rwxr-xr-x 1 root admin 281B Dec 23 13:31 pip_

$ pip --version pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (python 3.6) </syntaxhighlight>

  • I have moved pip tp pip_
  • I created the symbolic link to pip3.

Django

Now you can install Django. <syntaxhighlight lang="bash" line start="1"> $ pip install Django </syntaxhighlight>

If everything went alright, do: <syntaxhighlight lang="bash" line start="1"> $ $ python -m django --version 2.0

  1. Alternative

$ python Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> print(django.get_version()) 2.0 >>> quit() $ </syntaxhighlight>

See also

top

Reference

top

  1. Upgrade Python on Mac to version3., Download page for the installer of Python 3.6 on Apple Mac OSX.