[Tutor] Using venv
Jim
jf_byrnes at comcast.net
Mon May 29 21:47:12 EDT 2017
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 <jf_byrnes at comcast.net> 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.
>
More information about the Tutor
mailing list