Python3 - Django - MySQL
Linux
We decided to develop the application in linux because it seemed like most of the resources we were accessing regarding Django, Python3, and MySQL referenced linux commands more often than Windows. We chose Ubuntu as our distribution because we each already had it installed on our machines. Tutorials for installing Ubuntu are excellent and readily available. We chose to dual boot our windows operating systems with Ubuntu, which this tutorial describes how to do.
Python 3
Depending on the Linux distribution that you install, Python3 might already be installed. Try running python in a terminal to see what version is installed. If it's not installed, type
sudo apt-get -y install python3
at the command line and Python3 should be installed. Now you can run Python3 by typing python3 at the terminal.
Django
Django has a good set of instructions for installing their framework, the only caveat to observe is to make sure that when you run any 'python' commands you substitute 'python' with whatever version of python that you want to use. In our case, we found it easiest to manually install Django. When it came to the 4th step, we changed the command tosudo python3 setup.py installin order to make sure that Django was installed on Python 3. To make sure that it has been installed correctly, start the Python 3 command line and type in
import djangoIf the command line doesn't complain, then congratulations, you've officially installed Django!
MySQL
Unfortunately, Python3 and MySQL currently don't play nice together. This means that we have to install a third party application in order to use a MySQL database with Django. Quick Google searches turned up several options, the two most prominent of which were CyMySQL and PyMySQL. Ultimately we decided to go with PyMySQL because we were able to find more resources about the process of integrating Django with MySQL using this tool. A special thanks to this Stack Overflow response, which showed how easy it was to use PyMySQL.
MySQL
If you're like one of the members of our group, you don't yet have MySQL installed on your system. Following these steps might not be the most efficient way to install MySQL, but it will definitely get the job done.
- Open 'System Settings' and select 'Software Sources' under the 'System' group at the bottom of the page.
- Select the 'Other Software' tab and then check the 'Canonical Partners' box.
- Now in a terminal, type: sudo apt-get update
- Following that command, type: sudo apt-get install synaptic
- After the installation completes, open synaptic.
- Type "mysql" in the quick filter bar to find mysql packages. Select the box next to 'mysql-server-core-5.5' or whatever the most recent version is and install all of the dependent packages.
MySQL should now be installed, to check, you can enter the following command in a terminal:
mysql -VThe terminal should output the version information for MySQL.
setuptools
Installing setuptools, a necessary component of PyMySQL, is relatively simple and can even be done in one line! Here is the command to install it:wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python3If that command doesn't work, don't blame us, blame this website where we got our information.
PyMySQL
Special thanks are again due to this Stack Overflow response that described how to use PyMySQL to integrate Python3 and Django.
We couldn't figure out how to make pip work with Python3, so we used the manual installation method for installing PyMySQL. Here is a walk through of the process:
We couldn't figure out how to make pip work with Python3, so we used the manual installation method for installing PyMySQL. Here is a walk through of the process:
- Download the .zip folder for PyMySQL from gitHub.
- Unzip the contents, then navigate to the directory.
- Do this command: python3 setup.py install, or follow the instructions in the readme.rst to install.
- During the installation process, some error messages may appear, despite this, the installation may still be successful, try starting python3 and importing pymysql to make sure that it worked.
Eclipse
In order to use Python plugins with Eclipse, you'll need to be on the latest version. Arik found an excellent tutorial to install the most recent version of Eclipse on Ubuntu. Follow these steps and you should be golden.
PyDev
PyDev is a plugin for Eclipse that allows easy development of Python projects. It's super easy to install with the Eclipse software manager. In Eclipse, click on the "Help" menu at the top, then select "Install New Software..." In the "Work with:" field, copy and paste this web address: http://pydev.org/updates then check the PyDev checkbox and select "Next". Continue to make appropriate choices until PyDev is installed. PyDev gives you lots of useful commands for automatically building Django content and running tests.
No comments:
Post a Comment