Re: [Tutor] Using venv

2017-05-29 Thread Jim

On 05/29/2017 08:09 PM, Ben Finney wrote:

You should probably disregard this message as I have since solved the 
problem I was asking about. I originally wrote this message on 01/27/17, 
how it make it back to the list I don't know.


Regards,  Jim


Jim  writes:


It has been suggested to me that I should use a virtual environment
and venv would be a good choice. I've read through PEP405 and this
link [1].


One possible confusion is the terminology.

You have “a virtual environment” when you create one. The ‘venv’ module
is not itself a virtual environment; it is what you use to create one :-)


Though some of it seems a little confusing to me, I'm sure I can get
it up and running. This question seems a little dumb and maybe I am
being a little dense, but then what?


* In each shell where you want to be working in that virtual Python
   environment, activate the virtualenv (by running the commands from its
   corresponding ‘activate’ script; e.g. ‘source $VENV/bin/activate’).

* Do things requiring Python.


Your program/script is done how do you run it? Do you always have to
activate your venv and run it from there?


To get the benefits of that particular virtualenv, yes.


I like to run Tkinter programs from a launcher. Would that be possible
and what would the command look like?


How are the programs installed? Can you customise how they're launched?


Lately I have been writing some Libreoffice calc macros and evaluating
pyspread for it's macro capability. Would modules installed in my venv
be available to the spreadsheet programs?


The trick is that the environment variables for a process need to be set
either when the program starts, or within the program; it can't be done
externally. That isn't special to Python, it is how processes work.

The virtualenv is activated by setting particular shell environment
variables to specific values. If you can do that, the answer is yes.

The ‘source $VENV/bin/activate’ command just runs shell commands to set
those environment variables. It's not the only way to set those
environment variables.

Other Python-bundled programs, like LibreOffice or Blender, will likely
have their own ways of activating a virtualenv; or at least you'll
probably find people in those communities discussing how to do it.




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


Re: [Tutor] Using venv

2017-05-29 Thread Ben Finney
Jim  writes:

> It has been suggested to me that I should use a virtual environment
> and venv would be a good choice. I've read through PEP405 and this
> link [1].

One possible confusion is the terminology.

You have “a virtual environment” when you create one. The ‘venv’ module
is not itself a virtual environment; it is what you use to create one :-)

> Though some of it seems a little confusing to me, I'm sure I can get
> it up and running. This question seems a little dumb and maybe I am
> being a little dense, but then what?

* In each shell where you want to be working in that virtual Python
  environment, activate the virtualenv (by running the commands from its
  corresponding ‘activate’ script; e.g. ‘source $VENV/bin/activate’).

* Do things requiring Python.

> Your program/script is done how do you run it? Do you always have to
> activate your venv and run it from there?

To get the benefits of that particular virtualenv, yes.

> I like to run Tkinter programs from a launcher. Would that be possible
> and what would the command look like?

How are the programs installed? Can you customise how they're launched?

> Lately I have been writing some Libreoffice calc macros and evaluating
> pyspread for it's macro capability. Would modules installed in my venv
> be available to the spreadsheet programs?

The trick is that the environment variables for a process need to be set
either when the program starts, or within the program; it can't be done
externally. That isn't special to Python, it is how processes work.

The virtualenv is activated by setting particular shell environment
variables to specific values. If you can do that, the answer is yes.

The ‘source $VENV/bin/activate’ command just runs shell commands to set
those environment variables. It's not the only way to set those
environment variables.

Other Python-bundled programs, like LibreOffice or Blender, will likely
have their own ways of activating a virtualenv; or at least you'll
probably find people in those communities discussing how to do it.

-- 
 \   “I distrust those people who know so well what God wants them |
  `\to do to their fellows, because it always coincides with their |
_o__)  own desires.” —Susan Brownell Anthony, 1896 |
Ben Finney

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


Re: [Tutor] Using venv

2017-02-04 Thread Juan C.
On Fri, Jan 27, 2017 at 7:47 PM, Jim  wrote:
>
> [...] This question seems a little dumb and maybe I am being a little dense, 
> but then what?

Imagine that you are working on 5 different Python projects, each
using different packages with different versions. We can break this
down in two situations:

1. No virtualenv
1.a. You only have one Lib/site-packages to hold all your packages
1.b. Project A uses package-abc 1.2 while Project B uses package-abc 1.5
1.c. You go to work on Project B using package-abc 1.5, but later on
you have to do some changes on Project A so you must downgrade
package-abc to 1.2. Too bad you have to fix some bugs on Project B the
next day, need to update package-abc back to 1.5

2. Virtualenv
2.a. You had multiple virtualenvs, each of them having their own
Lib/site-packages
2.b. Project A uses one virtualenv with package-abc 1.2 while Project
B uses another virtualenv with package-abc 1.5
2.c. You go to work on Project B using package-abc 1.5, so you
activate its venv, but later on you have to do some changes on Project
A so you activate the other venv. Too bad you have to fix some bugs on
Project B the next day, activate Project B venv.

It's a simple command to activate/deactivate a venv vs all the work
you have to do when not using venv.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using venv

2017-01-28 Thread Jim

On 01/27/2017 04:49 PM, Cameron Simpson wrote:

On 27Jan2017 15:47, jim  wrote:

It has been suggested to me that I should use a virtual environment
and venv would be a good choice. I've read through PEP405 and this
link [1].
Though some of it seems a little confusing to me, I'm sure I can get
it up and running. This question seems a little dumb and maybe I am
being a little dense, but then what?

Your program/script is done how do you run it? Do you always have to
activate your venv and run it from there? I like to run Tkinter
programs from a launcher. Would that be possible and what would the
command look like? Lately I have been writing some Libreoffice calc
macros and evaluating pyspread for it's macro capability. Would
modules installed in my venv be available to the spreadsheet programs?


The mere act of using the python from inside the venv invokes a python
that runs off the venv, so all you really need to do is to contrive to
execute that python instead of the system python where you want it.

If your scripts start with something like this:

 #!/usr/bin/env python3

then you can simply contrive that "python3" is found from the
virtualenv. You might put a symlink in your personal $HOME/bin
directory, or source the venv's "activate" file from your shell's
profile (this making the venv searched ahead of the system paths), etc.

Or your launcher might simply invoke:

 $HOME/path/to/your/venv/bin/python your-tk-inter-script.py

Cheers,
Cameron Simpson 



Thank you. Got it up and running and tested it with a previously written 
Tkinter script, which works fine.


Regards,  Jim


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


Re: [Tutor] Using venv

2017-01-27 Thread Cameron Simpson

On 27Jan2017 15:47, jim  wrote:
It has been suggested to me that I should use a virtual environment 
and venv would be a good choice. I've read through PEP405 and this 
link [1].
Though some of it seems a little confusing to me, I'm sure I can get 
it up and running. This question seems a little dumb and maybe I am 
being a little dense, but then what?


Your program/script is done how do you run it? Do you always have to 
activate your venv and run it from there? I like to run Tkinter 
programs from a launcher. Would that be possible and what would the 
command look like? Lately I have been writing some Libreoffice calc 
macros and evaluating pyspread for it's macro capability. Would modules 
installed in my venv be available to the spreadsheet programs?


The mere act of using the python from inside the venv invokes a python that 
runs off the venv, so all you really need to do is to contrive to execute that 
python instead of the system python where you want it.


If your scripts start with something like this:

 #!/usr/bin/env python3

then you can simply contrive that "python3" is found from the virtualenv. You 
might put a symlink in your personal $HOME/bin directory, or source the venv's 
"activate" file from your shell's profile (this making the venv searched ahead 
of the system paths), etc.


Or your launcher might simply invoke:

 $HOME/path/to/your/venv/bin/python your-tk-inter-script.py

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


[Tutor] Using venv

2017-01-27 Thread Jim
It has been suggested to me that I should use a virtual environment and 
venv would be a good choice. I've read through PEP405 and this link [1].
Though some of it seems a little confusing to me, I'm sure I can get it 
up and running. This question seems a little dumb and maybe I am being a 
little dense, but then what?


Your program/script is done how do you run it? Do you always have to 
activate your venv and run it from there? I like to run Tkinter programs 
from a launcher. Would that be possible and what would the command look 
like? Lately I have been writing some Libreoffice calc macros and 
evaluating pyspread for it's macro capability. Would modules installed 
in my venv be available to the spreadsheet programs?



Thanks,  Jim


[1] https://realpython.com/blog/python/python-virtual-environments-a-primer/

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