committedandroider
committedandroider

Reputation: 9271

Why am I getting an invalid syntax error?

I am following a tutorial on installing the Requests library, a HTTP library for Python. Requests Installation Guide

The tutorial says to install the Requests library, simply run this command in my terminal

pip install requests

I didn't which terminal to run this command in but I first tried Windows cmd after downloading pip, the package management system used to install and manage software packages written in Python(shown below) enter image description here

I then tried the Python 3.4.2 terminal(shown below)

enter image description here

Does anyone know which terminal to run this command in and what my syntax error is for that terminal(tried both)? To me it's weird because the Python terminal was able to recognize pip but not install.....

Upvotes: 3

Views: 32375

Answers (4)

Instead of doing anything with PATH I suggest you use pip on command line with python -mpip, as in python -mpip install somepackage.

Upvotes: 1

A.J. Uppal
A.J. Uppal

Reputation: 19264

You are running the pip install from your shell. Exit from the shell and run it from your .

Upvotes: 4

dparadis28
dparadis28

Reputation: 101

You can also create a virtual environment for your project and install all the modules you would like to use. It looks like you are using a windows machine. The commands would be as follows

C:dirrectory_for_your_project>c:\Python34\python.exe c:\Python34\Tools\Scripts\pyvenv.py env  #create your environment
C:dirrectory_for_your_project>env\Scripts\activate.bat   #activate your enviornment
(env) C:dirrectory_for_your_project>pip install requests #pip modules you would like to include in your project
(env) C:dirrectory_for_your_project>python script.py     #run script

There is also a deactivate script for when you would like to exit the env. Make sure to activate the env whenever you are trying to run the script from the command line and all should be fine.

Note: This is just another solution to your problem and is based on personal preference. You should still add the necessary scripts to your path as this might come in handy in the future.

Upvotes: 1

Tamerz
Tamerz

Reputation: 947

pip.exe will be in the C:\Python34\Scripts folder. You can add that folder to your PATH environment variable if you want to run pip from anywhere, or you can just CD into the Scripts folder from where you are and run it.

Upvotes: 2

Related Questions