[Tutor] Using pip
mats at wichmann.us
Thu Jul 5 13:28:04 EDT 2018
On 07/05/2018 11:11 AM, James Reynolds wrote:
> On Thu, Jul 5, 2018 at 12:55 PM Hlavin, Matthew (GSFC-5460)[GSFC INTERNS] <
> matthew.hlavin at nasa.gov> 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
These days, it is suggested not to use pip as if it were a command by
itself, but as a module. This is because many systems have more than one
python version installed, and it's not clear if you'll get the version
of pip that matches the version of python you'll be using. To make that
more simple, suggest using **at a command prompt** as others have said:
python -m pip install -U pyvisa
pip install -U pyvisa
If you are using Windows, even if you've added python to your PATH, pip
may not be in the path, as it lives in the scripts subdirectory of the
place python was installed. This is another reason the "python -m pip"
way of calling may be easier to deal with.
Virtualenv instructions below are good by the way, as it's usually not a
great idea to install into "system locations" with pip. That's actually
what the "-U" in the invocation above is for - it means to not install
the new module in the system paths, but in a user-specific path.
> What version of Python did you install and what operating system are you
> the $ is just a command prompt and it isn't used for the above command.
> The important bit from your message is the "I even tried just using the
> word pip and an error said 'pip' is not defined".
> This means either A.) You have pip installed, but it's not on your path or
> B.) You don't have pip installed.
> If you installed latest python (which is 3.7), then you can can create a
> virtual env directly and just use that, which contains pip as well.
> (this all assumes that python is on your path already)
> python -m venv env
> this will create a virtual environment called "env".
> After you create your virtual environment, you activate it ".
> env/bin/activate". If you are windows it would be "env\Scripts\activate"
> Once activated, you can install your package like: pip install pyvisa
> you may also enjoy using ipython (pip install ipython) for this kind of use
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
More information about the Tutor