Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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://www.dmoz.org/Computers/Programming/Languages/Python/Books/"

...\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!

like image 326
Dave G Avatar asked Mar 01 '15 04:03

Dave G


1 Answers

By the way, U said after you run "pip --version" nothing was displayed, I think this means you didn't install python correctly, pip should be installed automatically after you install Python. Just remind, make sure set the right Python path to your computer system path, set the "path" variable to the correct python istalled path.
In my opinion, you should uninstall python, and reinstall again.Any problem please let me know.

like image 94
tolerious Avatar answered Oct 24 '22 17:10

tolerious