[Tutor] Using pip

2018-07-05 Thread Hlavin, Matthew (GSFC-5460)[GSFC INTERNS]
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.

Thanks for any help and insight
Matt Hlavin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using pip

2018-07-05 Thread Alan Gauld via Tutor
On 05/07/18 17:03, Hlavin, Matthew (GSFC-5460)[GSFC INTERNS] wrote:
> install the library using the line:
> $ pip install -U pyvisa
> When I type this line, I get a syntax error

The most common reason is that you are trying to type it
at the Python >>> prompt.
It should be typed at the OS prompt.
The $ is the traditional *nix prompt.
In Windows it will be something like

C:\WINDOWS>

It's not at all obvious that pip is an OS level tool, they
need to improve/clarify the docs to make that clear - as
does every site that uses pip! Its a very common error.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using pip

2018-07-05 Thread James Reynolds
On Thu, Jul 5, 2018 at 12:55 PM Hlavin, Matthew (GSFC-5460)[GSFC INTERNS] <
matthew.hla...@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
> issue.
>
> Thanks for any help and insight
> Matt Hlavin
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor



What version of Python did you install and what operating system are you
using?

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
case.

James
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using pip

2018-07-05 Thread Jim

On 07/05/2018 11:03 AM, 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.

Thanks for any help and insight
Matt Hlavin


It sounds like you are trying to install it from inside python. First 
make sure that pip is installed on your OS. Then install PyVISA from 
your commandline/terminal (which ever your OS provides). Also depending 
on which version of python you are using (2 or 3) you may have to type 
pip3 instead of just pip.


regards,  Jim


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using pip

2018-07-05 Thread Mats Wichmann
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.hla...@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
>> issue.

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

rather than

  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
> using?
> 
> 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
> case.
> 
> James
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
> 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using pip

2018-07-05 Thread Steven D'Aprano
On Thu, Jul 05, 2018 at 04:03:00PM +, 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.


-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor