heds1
heds1

Reputation: 3438

Python not working in terminal (Python 3.4.3, Windows 8.1)

I open cmd.exe in the installed directory and type 'python':

C:\Python34>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Basic math works fine:

>>> 4+4
8

I can import, but can't seem to do basic things like check the version, or use pip, etc.:

>>> import os
>>> os.getcwd()
'C:\\Python34'


>>> -version
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'version' is not defined


>>> import pip
>>> pip install flask
  File "<stdin>", line 1
    pip install flask
          ^
SyntaxError: invalid syntax

I'm relatively new to this so might be doing something stupid, but I can't figure out what's going on.

Upvotes: 0

Views: 409

Answers (2)

pylang
pylang

Reputation: 44475

Notice the triple chevrons (">>>") means you are inside the Python REPL. Install packages either:

  1. outside Python at the commandline (recommended)
  2. inside Python (less common)

Try the first option:

In cmd

> pip install requests
> python                                               # activates python

In Python

>>> import requests
>>> r = requests.get("https://www.google.com")
>>> r.status_code
200

Upvotes: 2

Rambarun Komaljeet
Rambarun Komaljeet

Reputation: 646

You cannot do pip install inside the python interpreter. Befor enterig the interpreter, try pip install, if you do not have pip, google for getpip.py.

Upvotes: 1

Related Questions