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

no edit summary
imported>Geography76
No edit summary
imported>Geography76
No edit summary
Line 44:
 
<ol>
<li>Click and save thesethe fourfollowing dependenciesfile to your Desktop directory:
 
* https://github.com/abatula/PythonWorkshop-Twitter/archive/master.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. Click 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 55 ⟶ 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 67 ⟶ 68:
</pre>
 
will show you the source code files in that directory. In this directory are five folders: Twitter (the main folder) and four dependency folders (simplejson-3.3.0, python-oauth2-master, httplib2-0.8, and python-twitter-1.0). 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:
 
<pre>
Line 73 ⟶ 74:
</pre>
 
and hit enter to install httplib2simplejson-3.3.0.
 
Navigate to the 32 other dependency directories (in the order you downloaded them: simplejsonpython-oath2-2.1.6master, python-twitter, python-oauth2) and run
 
<pre>
Line 81 ⟶ 82:
</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:
<pre>
 
python setup.py build
===Download the Twitter project===
python setup.py install
 
</pre>
We've written some skeleton code for the Twitter project already. Download this code so you're ready to start working with it:
 
# Right click the following file, click "Save Target as..." or "Save link as...", and save it to your Desktop directory:
#* http://web.mit.edu/jesstess/www/BostonPythonWorkshop6/Twitter.zip
#Find Twitter.zip on your Desktop and double-click on it to "unzip" it. That will create a folder called Twitter containing several files.
 
===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 105 ⟶ 103:
</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