[Tutor] Using pip

Steven D'Aprano steve at pearwood.info
Thu Jul 5 13:27:39 EDT 2018

On Thu, Jul 05, 2018 at 04:03:00PM +0000, Hlavin, Matthew (GSFC-5460)[GSFC INTERNS] wrote:
> I just downloaded Python to work on a project at work. I'm writing a 
> pretty simple program for data collection for an experiment. In order 
> to get the data, though I need to install PyVISA. The website for 
> PyVISA says I can install the library using the line:
> $ pip install -U pyvisa
> When I type this line, I get a syntax error for using the $, and when 
> I remove the $, I get a syntax error for using the word install. I 
> even tried just using the word pip and an error said 'pip' is not 
> defined. I'm not sure if I'm not using some syntax wrong, or if its a 
> completely different issue.

My crystal ball tells me you're using the Python interactive intepreter 

(By the way, in the future, please always copy and paste the full error 
messages you see. Don't use a screen shot.)

Does the line start with a prompt >>> ? Then you're already running 
inside Python. The above command is assumed to be inside a Linux "bash" 
shell. Type Ctrl-D or enter the command "quit()" (with the parentheses, 
but not the quotes) to exit. The command "exit()" will also work.

This should return you to the standard terminal shell, which on Linux is 
probably bash. You should see a $ (dollar sign) prompt.

If you do, then you can try running:

pip install -U pyvisa

at the dollar sign prompt (don't retype the $) but don't be surprised if 
it fails again. pip is a great tool, *once you get it working right*, 
but getting it working is often a dozen kinds of pain.

If it works, GREAT! But if you get an error, please copy and paste all 
the output and we'll see what we can see.

All of the above assume you are running Linux. If you're on Windows, the 
commands needed will be slightly different.

Let's start with:

- what OS are you running? Windows, Linux, Mac OS, something else?

- do you have sudo/root/Administrator privileges on that machine?

- what version of Python are you running?

- what command or action do you use to start Python?

If you're running Linux or Mac OS, you can also run this command at the 
dollar sign $ prompt:

which pip

and see what it says.


More information about the Tutor mailing list