Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Setting Up a Local Python Environment Installing Python and Python Libraries Locally Using pip

John Reilly
John Reilly
10,800 Points

pip windows 7 'pip' not defined

In CMD I run python as shown, then type pip as shown. A NameError occurs and says name 'pip' not defined. What am I doing incorrect? I have installed python 3.4.2 as shown allowing me to use python in CMD without typing full directory.

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

Thanks in advanced guys :D

Hi John,

Checkout this thread where I tried helping with a similar issue.

2 Answers

do not type pip inside the python . instead when you have openned the python first exit it then type pip well before you openned pyhton in cmd.

Good catch on pip being in a file instead of typed at the CLI.

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

The easiest way to install pip is to download the get-pip.py script, save it locally, then run it using Python:

PS C:\> python get-pip.py
Downloading/unpacking pip
Downloading/unpacking setuptools
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...
PS C:\>
Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Assuming OP followed the instructions in Setting Up a Local Python Environment, there's no reason to use get-pip. The installer will install pip for you.

i get this when i try running it with python Exception: Traceback (most recent call last): File "/var/folders/jd/c2fw51_12kd7qhsvdhl9hglr0000gn/T/tmppskS96/pip.zip/pip/basecommand.py", line 223, in main status = self.run(options, args) File "/var/folders/jd/c2fw51_12kd7qhsvdhl9hglr0000gn/T/tmppskS96/pip.zip/pip/commands/install.py", line 297, in run root=options.root_path, File "/var/folders/jd/c2fw51_12kd7qhsvdhl9hglr0000gn/T/tmppskS96/pip.zip/pip/req/req_set.py", line 622, in install **kwargs File "/var/folders/jd/c2fw51_12kd7qhsvdhl9hglr0000gn/T/tmppskS96/pip.zip/pip/req/req_install.py", line 808, in install self.move_wheel_files(self.source_dir, root=root) File "/var/folders/jd/c2fw51_12kd7qhsvdhl9hglr0000gn/T/tmppskS96/pip.zip/pip/req/req_install.py", line 1003, in move_wheel_files isolated=self.isolated, File "/var/folders/jd/c2fw51_12kd7qhsvdhl9hglr0000gn/T/tmppskS96/pip.zip/pip/wheel.py", line 339, in move_wheel_files clobber(source, lib_dir, True) File "/var/folders/jd/c2fw51_12kd7qhsvdhl9hglr0000gn/T/tmppskS96/pip.zip/pip/wheel.py", line 310, in clobber ensure_dir(destdir) File "/var/folders/jd/c2fw51_12kd7qhsvdhl9hglr0000gn/T/tmppskS96/pip.zip/pip/utils/init.py", line 70, in ensure_dir os.makedirs(path) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'