Philadelphia Python Workshop 9/Setup/Windows project dependencies: Difference between revisions

imported>Geography76
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 44:
 
<ol>
<li>Click and save thesethe fourfollowing dependenciesfile to your Desktop directory:
 
* https://github.com/abatula/PythonWorkshop-Twitter/archive/master.zip
* http://mit.edu/jesstess/www/BostonPythonWorkshop6/Twitter/httplib2-0.6.0.zip
* http://mit.edu/jesstess/www/BostonPythonWorkshop6/Twitter/simplejson-2.1.6.zip
* http://mit.edu/jesstess/www/BostonPythonWorkshop6/Twitter/python-twitter.zip
* http://mit.edu/jesstess/www/BostonPythonWorkshop6/Twitter/python-oauth2.zip
 
</li>
<li>
The ".zip" extension on the above files indicates that they are compressed Zip archives. We need to "extract" their contents. To do this, click on "Start", then "Computer", and navigate to your Desktop directory. For each of the 4 zip files, clickClick on the file and click the "Extract all files" button to extract the contents. This will create a directory for each file, containing the source code for the dependency.
</li>
</ol>
Line 59 ⟶ 56:
===Install the Twitter project dependencies===
 
Open a command prompt and navigate to the unzipped folder. For example, if you extracted the folder to C:\Users\myname\Desktop\PythonWorkshop-Twitter-master,
Each of these 4 dependencies has an installer script that we'll need to run at a command prompt to install the software. '''It is important that the dependencies are installed in the order listed above.''' For each project, start a command prompt and navigate to the Desktop directory where the source code lives. For example, if the httplib2-0.6.0 project was extracted to C:\Users\jesstess\Desktop\httplib2-0.6.0,
 
<pre>
cd C:\Users\jesstessmyname\Desktop\httplib2PythonWorkshop-0.6.0Twitter-master
</pre>
 
Line 71 ⟶ 68:
</pre>
 
will show you the source code files in that directory. OneIn ofthis directory are five folders: Twitter (the filesmain isfolder) "setupand four dependency folders (simplejson-3.py"3.0, whichpython-oauth2-master, hashttplib2-0.8, aand "python-twitter-1.0).py" extensionYou indicatingwill thatalso it issee a Pythonfile scriptcalled ez_setup.py. Type:
 
Before we can install the dependencies, we must first install some setup tools using ez_setup.py. To do this, change directory into the ez_setup folder and type:
 
<pre>
python setupez_setup.py install
</pre>
 
Now, we are ready to install the dependencies. Three of the dependency subfolders have an installer script that we'll need to run at a command prompt to install the software. For each dependency (in the order: simplejson-3.3.0 python-oauth2-master httplib2-0.8) navigate to the folder using cd. One of the files in this subfolder is "setup.py", which has a ".py" extension indicating that it is a Python script. Type:
and hit enter to install httplib2.
 
Navigate to the 3 other dependency directories (in the order you downloaded them: simplejson-2.1.6, python-twitter, python-oauth2) and run
 
<pre>
Line 85 ⟶ 82:
</pre>
 
inand allhit of thementer to install those dependencies as wellsimplejson-3.3.0.
 
Navigate to the 32 other dependency directories (in the order you downloaded them: simplejson-2.1.6, python-twitteroath2-master, pythonhttplib2-oauth20.8) and run
===Download the Twitter project===
 
<pre>
We've written some skeleton code for the Twitter project already. Download this code so you're ready to start working with it:
python setup.py install
</pre>
 
in all of them to install those dependencies as well. Now use cd to move into the python-twitter-1.0 folder. This time we will run the two following commands to install the dependency:
# Right click the following file, click "Save Target as..." or "Save link as...", and save it to your Desktop directory:
<pre>
#* http://web.mit.edu/jesstess/www/BostonPythonWorkshop6/Twitter.zip
python setup.py build
#Find Twitter.zip on your Desktop and double-click on it to "unzip" it. That will create a folder called Twitter containing several files.
python setup.py install
</pre>
 
===Test the Twitter code===
 
Start a command prompt and navigateNavigate to the Desktop\Twitter directorysubfolder where the Twitter code lives. For example, if the Twitter project is at <code>C:\Users\jesstessmyname\Desktop\PythonWorkshop-Twitter-master\Twitter</code>,
 
<pre>
cd C:\Users\jesstessmyname\Desktop\PythonWorkshop-Twitter-master\Twitter
</pre>
 
Line 109 ⟶ 110:
</pre>
 
will show you the source code files in that directory. One of the files is "twitter_apitwitter_functions.py", which has a ".py" extension indicating that it is a Python script. TypeOpen this file in your text editor and find the line that says:
<pre>
CONSUMER_SECRET = 'We will give this to you in class :)'
</pre>
 
Change the string to the consumer secret string that we will give you in class. Save the file and go back to the command line. The file "twitter_api.py" is also a Python script. Type:
 
<pre>
Anonymous user