samedi 28 février 2015

Python Script Output Does Not Appear in CMD

While working through the Scrapy tutorial here I noticed that Python scripts are not resulting in any output to the Windows command prompt.


I did check the path environment variable to confirm that "c:\python27" and "c:\python27\Scripts" are both included. And do I believe I successfully installed Scrapy and the required dependencies.


I was able to follow along with the tutorial right up to Trying Selectors in the Shell. Up to that point most things went as anticipated: the output files were created as expected; however, no console output appeared. According to the tutorial, I should have seen something like the following:



2014-01-23 18:13:07-0400 [scrapy] INFO: Scrapy started (bot: tutorial)
2014-01-23 18:13:07-0400 [scrapy] INFO: Optional features available: ...
...


Initially I did not notice there was no output to the console and moved on to trying to launch the shell as described in the tutorial:



...\tutorial\>scrapy shell "http://ift.tt/1dpxGzU"

...\tutorial\>


There is no output, but there is a pause before the prompt re-appears, so it is obviously thinking...


I searched with Google and here at SO; but had no luck finding a solution. Though, in the process of trying to diagnose this issue, I noticed that other scripts that should output to the console are not doing so (python.exe, however, does).


For example, as expected:



C:\>python --version


results in:



Python 2.7.6


On the other hand, I get nothing from pip:



C:\>pip --version

C:\>


Pip is installed. I can re-direct output to a text file:



C:\>pip list 1>output.txt 2>&1

C:\>


The resulting text file includes the following, as expected:



...
nose (1.3.4)
numpy (1.8.1)
pip (6.0.8)
...


I saved a script 'time.py' containing the following:



import datetime
print datetime.datetime.now()


And running it works fine:



...\Desktop>time.py
2015-02-28 21:23:18.088000

...\Desktop>


So now I am thoroughly confused. How can I get pip, Scrapy, etc. to output to windows command prompt? Thanks in advance!


Aucun commentaire:

Enregistrer un commentaire