Why am I getting an invalid syntax error?

I am following the tutorial to install Requests library, an HTTP library for Python. Query Installation Guide

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

pip install requests


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

Then I tried Python 3.4.2 terminal (shown below)

enter image description here

Does anyone know which terminal is running this command and what is my syntax error for that terminal (tried both)? This is strange to me because the Python terminal was able to recognize the pip but not install .....


source to share

4 answers

You can also create a virtual environment for your project and install all the modules you want to use. It looks like you are using a windows machine. The commands will look like this

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 if you want to exit the env. Make sure to activate env whenever you try to run your script from command line and you should be fine.

Note. It's just a different solution to your problem and based on personal preference. You should still add the required scripts to your path as it may come in handy in the future.



You are using pip install

fromshell. Get out of shell and run it from your ...



pip.exe will be in the folder C:\Python34\Scripts

. You can add this folder to your PATH environment variable if you want to run pip from anywhere, or you can just burn a CD to the Scripts folder where you are and run it.



Instead of doing anything with anything PATH

, I suggest you use with pip

on the command line python -mpip

, as in python -mpip install somepackage




All Articles