Re: The GIL and PyEval_RestoreThread
The thread variable I'm passing in is the one I originally got from calling
Py_NewInterpreter. I'd assumed that I didn't need to particularly track the
one I get back from SaveThread since it should always be the one I restored
previously (which does seem to be the case).
> It looks like you're resuming the same thread twice. As it's already
resumed the second time, no wonder it's not blocking!
That isn't how I read the docs though? It says "If the lock has been
created, the current thread must not have acquired it, otherwise deadlock
ensues." That suggests to me that it should try to acquire the GIL again
and wait until it can (although possibly also that it's not an expected use
and Python thread states are expected to be more 1:1 with C threads).
On Wed, Sep 27, 2023 at 3:53 AM MRAB via Python-list
wrote:
> On 2023-09-26 14:20, Peter Ebden via Python-list wrote:
> > Hi all,
> >
> > I've been working on embedding Python and have an interesting case around
> > locking with PyEval_RestoreThread which wasn't quite doing what I expect,
> > hoping someone can explain what I should expect here.
> >
> > I have a little example (I'm running this in parallel from two different
> > threads; I have some more C code for that but I don't think it's super
> > interesting):
> >
> > void run_python(PyThreadState* thread) {
> >LOG("Restoring thread %p...", thread);
> >PyEval_RestoreThread(thread);
> >LOG("Restored thread %p", thread);
> >PyRun_SimpleString("import time; print('sleeping'); time.sleep(3.0)");
> >LOG("Saving thread...");
> >PyThreadState* saved_thread = PyEval_SaveThread();
> >LOG("Saved thread %p", saved_thread);
> > }
> >
> > This produces output like
> > 11:46:48.110058893: Restoring thread 0xabc480...
> > 11:46:48.110121656: Restored thread 0xabc480
> > 11:46:48.110166060: Restoring thread 0xabc480...
> > sleeping
> > 11:46:48.110464194: Restored thread 0xabc480
> > sleeping
> > 11:46:51.111307541: Saving thread...
> > 11:46:51.111361075: Saved thread 0xabc480
> > 11:46:51.113116633: Saving thread...
> > 11:46:51.113177605: Saved thread 0xabc480
> >
> > The thing that surprises me is that both threads seem to be able to pass
> > PyEval_RestoreThread before either reaches the corresponding
> > PyEval_SaveThread call, which I wasn't expecting to happen; I assumed
> that
> > since RestoreThread acquires the GIL, that thread state would remain
> locked
> > until it's released.
> >
> > I understand that the system occasionally switches threads, which I guess
> > might well happen with that time.sleep() call, but I wasn't expecting the
> > same thread to become usable somewhere else. Maybe I am just confusing
> > things by approaching the same Python thread from multiple OS threads
> > concurrently and should be managing my own locking around that?
> >
> Storing the result of PyEval_SaveThread in a local variable looks wrong
> to me.
>
> In the source for the regex module, I release the GIL with
> PyEval_SaveThread and save its result. Then, when I want to claim the
> GIL, I pass that saved value to PyEval_RestoreThread.
>
> You seem to be releasing the GIL and discarding the result, so which
> thread are you resuming when you call PyEval_RestoreThread?
>
> It looks like you're resuming the same thread twice. As it's already
> resumed the second time, no wonder it's not blocking!
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
Thought Machine Group Limited, a company registered in England & Wales.
Registered number: 4277.
Registered Office: 5 New Street Square,
London EC4A 3TW
.
The content of this email is confidential and intended for the recipient
specified in message only. It is strictly forbidden to share any part of
this message with any third party, without a written consent of the sender.
If you received this message by mistake, please reply to this message and
follow with its deletion, so that we can ensure such a mistake does not
occur in the future.
--
https://mail.python.org/mailman/listinfo/python-list
venv --upgrade 3.12.0rc2 --> 3.12.0rc3 failure
Attempting venv upgrade 3.12.0rc2 --> 3.12.0rc3 I find pyvenv.cfg changes, but the virtual python doesn't. I guess this ought to be a bug. user@host:~/devel $ ~/LOCAL?3.12.0rc2/bin/python3 -m venv xxx bash: /home/user/LOCAL?3.12.0rc2/bin/python3: No such file or directory user@host:~/devel $ ~/LOCAL/3.12.0rc2/bin/python3 -m venv xxx user@host:~/devel $ xxx/bin/python -c'import sys;print(sys.version)' 3.12.0rc2 (main, Sep 9 2023, 17:53:34) [GCC 13.2.1 20230801] user@host:~/devel $ cat xxx/pyvenv.cfg home = /home/user/LOCAL/3.12.0rc2/bin include-system-site-packages = false version = 3.12.0 executable = /home/user/LOCAL/3.12.0rc2/bin/python3.12 command = /home/user/LOCAL/3.12.0rc2/bin/python3 -m venv /home/robin/devel/xxx user@host:~/devel $ ~/LOCAL/3.12.0rc3/bin/python3 -m venv --upgrade xxx user@host:~/devel $ xxx/bin/python -c'import sys;print(sys.version)' 3.12.0rc2 (main, Sep 9 2023, 17:53:34) [GCC 13.2.1 20230801] user@host:~/devel $ cat xxx/pyvenv.cfg home = /home/user/LOCAL/3.12.0rc3/bin include-system-site-packages = false version = 3.12.0 executable = /home/user/LOCAL/3.12.0rc3/bin/python3.12 command = /home/user/LOCAL/3.12.0rc3/bin/python3 -m venv --upgrade /home/robin/devel/xxx user@host:~/devel $ # check versions > user@host:~/devel $ ~/LOCAL/3.12.0rc2/bin/python3 -c'import sys;print(sys.version)' 3.12.0rc2 (main, Sep 9 2023, 17:53:34) [GCC 13.2.1 20230801] > user@host:~/devel $ ~/LOCAL/3.12.0rc3/bin/python3 -c'import sys;print(sys.version)' 3.12.0rc3 (main, Sep 27 2023, 09:35:10) [GCC 13.2.1 20230801] user@host:~/devel $ -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to uninstall 3.10.9
On 9/25/23 12:10, Pau Vilchez via Python-list wrote: Hello Python Team, I am somehow unable to completely remove Python 3.10.9 (64 Bit) from my computer. I have tried deleting the Appdata folder then repairing and then uninstalling but it still persists in the remove/add program function in windows 10. I am just trying to reinstall it because I didn’t add it to the path correctly, any help is greatly appreciated. Rerunning the installer and telling it uninstall should normally work (if you can't get to that from the Programs applet, then you can start from the installer itself). You can also fix the path addition from the Modify screen in the installer, you don't need to uninstall for that. If it's really stuck, the Windows installer subsystem could have gotten confused, usually this tool works for folks: https://support.microsoft.com/en-us/topic/fix-problems-that-block-programs-from-being-installed-or-removed-cca7d1b6-65a9-3d98-426b-e9f927e1eb4d -- https://mail.python.org/mailman/listinfo/python-list
upgrade of pip on my python 2.7 version
hello everyone this the error that im getting while trying to install and upgrade pip on what is the solution for it? C:\repository\pst-utils-pc-davinci-simulator>pip install You are using pip version 7.0.1, however version 23.2.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. You must give at least one requirement to install (see "pip help install") C:\repository\pst-utils-pc-davinci-simulator>pip install --upgrade pip You are using pip version 7.0.1, however version 23.2.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting pip Using cached https://files.pythonhosted.org/packages/ba/19/e63fb4e0d20e48bd2167bb7e857abc0e21679e24805ba921a224df8977c0/pip-23.2.1.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 20, in File "c:\users\kuchipz\appdata\local\temp\pip-build-gc4ekm\pip\setup.py", line 7 def read(rel_path: str) -> str: ^ SyntaxError: invalid syntax Command "python setup.py egg_info" failed with error code 1 in c:\users\kuchipz\appdata\local\temp\pip-build-gc4ekm\pip -- https://mail.python.org/mailman/listinfo/python-list
Re: upgrade of pip on my python 2.7 version
On 9/27/2023 7:17 AM, Zuri Shaddai Kuchipudi via Python-list wrote: hello everyone this the error that im getting while trying to install and upgrade pip on what is the solution for it? C:\repository\pst-utils-pc-davinci-simulator>pip install You are using pip version 7.0.1, however version 23.2.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. You must give at least one requirement to install (see "pip help install") C:\repository\pst-utils-pc-davinci-simulator>pip install --upgrade pip You are using pip version 7.0.1, however version 23.2.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting pip Using cached https://files.pythonhosted.org/packages/ba/19/e63fb4e0d20e48bd2167bb7e857abc0e21679e24805ba921a224df8977c0/pip-23.2.1.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 20, in File "c:\users\kuchipz\appdata\local\temp\pip-build-gc4ekm\pip\setup.py", line 7 def read(rel_path: str) -> str: ^ SyntaxError: invalid syntax Command "python setup.py egg_info" failed with error code 1 in c:\users\kuchipz\appdata\local\temp\pip-build-gc4ekm\pip Possibly this: https://techglimpse.com/install-higher-version-pip-python27/ -- https://mail.python.org/mailman/listinfo/python-list
Re: upgrade of pip on my python 2.7 version
On Thu, 28 Sept 2023 at 01:16, Zuri Shaddai Kuchipudi via Python-list wrote: > > hello everyone this the error that im getting while trying to install and > upgrade pip on what is the solution for it? > The solution is to upgrade to Python 3. https://pip.pypa.io/en/latest/development/release-process/#python-2-support ChrisA -- https://mail.python.org/mailman/listinfo/python-list
path to python in venv
I was under the impression that in a venv the python used would be in the venv's bin dir. But in my venvs I see this in the bin dirs: lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> /usr/bin/python3 Googling this I read: The presence of symbolic links like python and python3 in the bin directory of your virtual environment pointing to the system Python executable (/usr/bin/python) suggests that the virtual environment was created using the system Python interpreter rather than a standalone Python installation. This can happen if you create a virtual environment using a system-wide Python interpreter, and the virtual environment inherits some of the symbolic links or shortcuts from the system Python installation. In this case, your virtual environment is not fully isolated because it still relies on the system Python interpreter. Not sure what this really means, nor how to get python to be in my venv. -- https://mail.python.org/mailman/listinfo/python-list
Re: upgrade of pip on my python 2.7 version
On 9/27/23 05:17, Zuri Shaddai Kuchipudi via Python-list wrote: hello everyone this the error that im getting while trying to install and upgrade pip on what is the solution for it? C:\repository\pst-utils-pc-davinci-simulator>pip install You are using pip version 7.0.1, however version 23.2.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. You must give at least one requirement to install (see "pip help install") C:\repository\pst-utils-pc-davinci-simulator>pip install --upgrade pip You are using pip version 7.0.1, however version 23.2.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting pip Using cached https://files.pythonhosted.org/packages/ba/19/e63fb4e0d20e48bd2167bb7e857abc0e21679e24805ba921a224df8977c0/pip-23.2.1.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 20, in File "c:\users\kuchipz\appdata\local\temp\pip-build-gc4ekm\pip\setup.py", line 7 def read(rel_path: str) -> str: ^ SyntaxError: invalid syntax PyPI *should* be returning a compatible version of pip to upgrade to. pip itself has long since dropped support for 2.7, and the version you're trying to force is pretty clear: pip 23.2.1 Meta License: MIT License (MIT) Author: The pip developers Requires: Python >=3.7 ... Classifiers Development Status 5 - Production/Stable Intended Audience Developers License OSI Approved :: MIT License Programming Language Python Python :: 3 Python :: 3 :: Only ... So "don't do that". Why it's trying to select an incompatible version when you ask to upgrade is not something I'd like to speculate on, for me personally that's a surprise. Maybe something else you did before? Also make sure you're using a pip that matches your Python. It's usually safer if you invoke it as: python -m pip install --upgrade pip (or whatever the precise name of your Python 2 interpreter actually is) -- https://mail.python.org/mailman/listinfo/python-list
Re: path to python in venv
On 2023-09-27, Larry Martell wrote: > I was under the impression that in a venv the python used would be in > the venv's bin dir. But in my venvs I see this in the bin dirs: > > lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 > lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> > /usr/bin/python3 ... > Not sure what this really means, nor how to get python to be in my venv. WHy do you want python to be "in your venv"? -- https://mail.python.org/mailman/listinfo/python-list
Re: path to python in venv
On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list wrote: > > On 2023-09-27, Larry Martell wrote: > > I was under the impression that in a venv the python used would be in > > the venv's bin dir. But in my venvs I see this in the bin dirs: > > > > lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 > > lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> > > /usr/bin/python3 > ... > > Not sure what this really means, nor how to get python to be in my venv. > > WHy do you want python to be "in your venv"? Isn't that the entire point of a venv? To have a completely self contained env? So if someone messes with the system python it will not break code running in the venv. -- https://mail.python.org/mailman/listinfo/python-list
RE: path to python in venv
Hi Larry, You could just create venv with option '—copies' For example: python -m venv -–copies .venv From: Larry Martell via Python-list Sent: 27 сентября 2023 г. 22:48 To: Jon Ribbens Cc: [email protected] Subject: Re: path to python in venv On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list wrote: > > On 2023-09-27, Larry Martell wrote: > > I was under the impression that in a venv the python used would be in > > the venv's bin dir. But in my venvs I see this in the bin dirs: > > > > lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 > > lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> > > /usr/bin/python3 > ... > > Not sure what this really means, nor how to get python to be in my venv. > > WHy do you want python to be "in your venv"? Isn't that the entire point of a venv? To have a completely self contained env? So if someone messes with the system python it will not break code running in the venv. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: path to python in venv
On Wed, Sep 27, 2023 at 12:53 PM Niktar Lirik wrote: > > Hi Larry, > > You could just create venv with option '—copies' > > > > For example: > > python -m venv -–copies .venv Thanks! That is just what I was looking for. > From: Larry Martell via Python-list > Sent: 27 сентября 2023 г. 22:48 > To: Jon Ribbens > Cc: [email protected] > Subject: Re: path to python in venv > > > > On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list > > wrote: > > > > > > On 2023-09-27, Larry Martell wrote: > > > > I was under the impression that in a venv the python used would be in > > > > the venv's bin dir. But in my venvs I see this in the bin dirs: > > > > > > > > lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 > > > > lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> > > > > /usr/bin/python3 > > > ... > > > > Not sure what this really means, nor how to get python to be in my venv. > > > > > > WHy do you want python to be "in your venv"? > > > > Isn't that the entire point of a venv? To have a completely self > > contained env? So if someone messes with the system python it will not > > break code running in the venv. > > -- > > https://mail.python.org/mailman/listinfo/python-list > > -- https://mail.python.org/mailman/listinfo/python-list
Re: path to python in venv
On 9/27/23 13:46, Larry Martell via Python-list wrote: On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list wrote: On 2023-09-27, Larry Martell wrote: I was under the impression that in a venv the python used would be in the venv's bin dir. But in my venvs I see this in the bin dirs: lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> /usr/bin/python3 ... Not sure what this really means, nor how to get python to be in my venv. WHy do you want python to be "in your venv"? Isn't that the entire point of a venv? To have a completely self contained env? So if someone messes with the system python it will not break code running in the venv. It can do that, it just turns out the defaults are to not make a dedicated Python instance, and to not give access to the system site packages. The venv and virtualenv modules, at least, will let you override either of those defaults via command-line options at creation time. Once a year I have virtualenvs break when the new Python version appears in Fedora, which is irritating, but I take the attitude that virtualenvs are disposable and (try to) not let it bother me that I forgot to deal with that ahead of time. It helps if you make sure that a virtualenv has a record of its dependencies - perhaps a requirements.txt file in the project it's being used to build, so it's easy to recreate them. -- https://mail.python.org/mailman/listinfo/python-list
Re: upgrade of pip on my python 2.7 version
On Wednesday, 27 September 2023 at 21:32:53 UTC+2, Mats Wichmann wrote: > On 9/27/23 05:17, Zuri Shaddai Kuchipudi via Python-list wrote: > > hello everyone this the error that im getting while trying to install and > > upgrade pip on what is the solution for it? > > > > C:\repository\pst-utils-pc-davinci-simulator>pip install > > You are using pip version 7.0.1, however version 23.2.1 is available. > > You should consider upgrading via the 'pip install --upgrade pip' command. > > You must give at least one requirement to install (see "pip help install") > > > > C:\repository\pst-utils-pc-davinci-simulator>pip install --upgrade pip > > You are using pip version 7.0.1, however version 23.2.1 is available. > > You should consider upgrading via the 'pip install --upgrade pip' command. > > Collecting pip > > Using cached > > https://files.pythonhosted.org/packages/ba/19/e63fb4e0d20e48bd2167bb7e857abc0e21679e24805ba921a224df8977c0/pip-23.2.1.tar.gz > > > > Complete output from command python setup.py egg_info: > > Traceback (most recent call last): > > File "", line 20, in > > File "c:\users\kuchipz\appdata\local\temp\pip-build-gc4ekm\pip\setup.py", > > line 7 > > def read(rel_path: str) -> str: > > ^ > > SyntaxError: invalid syntax > PyPI *should* be returning a compatible version of pip to upgrade to. > pip itself has long since dropped support for 2.7, and the version > you're trying to force is pretty clear: > > pip 23.2.1 > > Meta > License: MIT License (MIT) > Author: The pip developers > Requires: Python >=3.7 > ... > Classifiers > Development Status > 5 - Production/Stable > Intended Audience > Developers > License > OSI Approved :: MIT License > Programming Language > Python > Python :: 3 > Python :: 3 :: Only > ... > > So "don't do that". > > Why it's trying to select an incompatible version when you ask to > upgrade is not something I'd like to speculate on, for me personally > that's a surprise. Maybe something else you did before? > > Also make sure you're using a pip that matches your Python. It's usually > safer if you invoke it as: > > python -m pip install --upgrade pip > > (or whatever the precise name of your Python 2 interpreter actually is) the code that i want to run and all the libraries are written for python 2 but i have seen a video where the person showed the 2to3 pip method in which it rewrites the code in python 3 and shows all the necessary changes. -- https://mail.python.org/mailman/listinfo/python-list
Re: path to python in venv
On 2023-09-27, Larry Martell wrote: > On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list > wrote: >> On 2023-09-27, Larry Martell wrote: >> > I was under the impression that in a venv the python used would be in >> > the venv's bin dir. But in my venvs I see this in the bin dirs: >> > >> > lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 >> > lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> >> > /usr/bin/python3 >> ... >> > Not sure what this really means, nor how to get python to be in my venv. >> >> WHy do you want python to be "in your venv"? > > Isn't that the entire point of a venv? To have a completely self > contained env? So if someone messes with the system python it will not > break code running in the venv. The main point of the venv is to isolate the installed packages, rather than Python itself. I'm a bit surprised your symlinks are as shown above though - mine link from python to python3.11 to /usr/bin/python3.11, so it wouldn't change the version of python used even if I installed a different system python version. -- https://mail.python.org/mailman/listinfo/python-list
Re: upgrade of pip on my python 2.7 version
On 9/27/23 14:02, Zuri Shaddai Kuchipudi via Python-list wrote: Why it's trying to select an incompatible version when you ask to upgrade is not something I'd like to speculate on, for me personally that's a surprise. Maybe something else you did before? Also make sure you're using a pip that matches your Python. It's usually safer if you invoke it as: python -m pip install --upgrade pip (or whatever the precise name of your Python 2 interpreter actually is) the code that i want to run and all the libraries are written for python 2 but i have seen a video where the person showed the 2to3 pip method in which it rewrites the code in python 3 and shows all the necessary changes. Upgrading to Python 3 is the best answer... except when it isn't. If you want to convert a small project it's usually not too hard; and using a conversion tool can work well. If you have libraries "not under your control" expect a lot more work. You can upgrade pip to the latest available version for Python 2.7 - will take some research, I don't know what that version might be. Or you could try this: https://bootstrap.pypa.io/pip/2.7/get-pip.py If you were using a Linux distro, you probably don't want to mess with the "system pip" which is usually set up to understand details of how that distro's Python is packaged. It looks like you're on Windows by the paths in your original message, so that should be okay. Or... you could just ignore the message suggesting you upgrade pip, and proceed, hoping things will stay working as they are. -- https://mail.python.org/mailman/listinfo/python-list
Re: upgrade of pip on my python 2.7 version
On Thu, 28 Sept 2023 at 07:27, Mats Wichmann via Python-list wrote: > > Upgrading to Python 3 is the best answer... except when it isn't. If > you want to convert a small project it's usually not too hard; and using > a conversion tool can work well. Just remember that Python 2.7.18, the very last version of Python 2, was released in 2020 and has not changed since. There are not even security patches being released (at least, not from python.org - but if you're using a different distribution of Python, you are also quite possibly using their package manager rather than pip). Staying on a version of Python that hasn't had new features since 2010 and hasn't had bug fixes since 2020 is going to become increasingly problematic. Convert your code. Pay the price in development time now and then reap the benefits, rather than paying the price when you run into a massive issue somewhere down the track and there's no options left to you. Convert while you still have the luxury of running the old code. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: path to python in venv
On 28/09/2023 09.32, Jon Ribbens via Python-list wrote: On 2023-09-27, Larry Martell wrote: On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list wrote: On 2023-09-27, Larry Martell wrote: I was under the impression that in a venv the python used would be in the venv's bin dir. But in my venvs I see this in the bin dirs: lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> /usr/bin/python3 ... Not sure what this really means, nor how to get python to be in my venv. WHy do you want python to be "in your venv"? Isn't that the entire point of a venv? To have a completely self contained env? So if someone messes with the system python it will not break code running in the venv. The main point of the venv is to isolate the installed packages, rather than Python itself. I'm a bit surprised your symlinks are as shown above though - mine link from python to python3.11 to /usr/bin/python3.11, so it wouldn't change the version of python used even if I installed a different system python version. "venv — Creation of virtual environments" (https://docs.python.org/3/library/venv.html) starts by saying: «The venv module supports creating lightweight “virtual environments”, each with their own independent set of Python packages installed in their site directories.» but later expands this with: «Used to contain a specific Python interpreter...» even though the primary use-case treats the system interpreter as the "base" Python/environment. Time for some reading and proving appropriate combinations of options? Over the years there have been various proposals to enable multiple versions of Python to exist concurrently on a single machine, notably Python2 + Python3 - but am failing to recall any official docs on Python3.n + Python3.m; eg "PEP 554 – Multiple Interpreters in the Stdlib" (https://peps.python.org/pep-0554/). That said there's plenty of articles on-line (which may/not feature venv*) such as "Multiple Python interpreters" (https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html) * although the OP didn't mention an OpSys, one poster did mention Fedora-Linux... NB some of this info may be dated - it is some time since conducted this investigation (and decided not to use venv - apologies!) Am currently using PyCharm (courtesy of recent teams' conventions) and it eases both problems (which interpreter, and which development-environment/activation steps) but in automating 'the boring stuff' it will be interesting to see if in-future, I notice when the project is based upon an older system! FYI https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-reloading-interpreter-paths.html (I'd be surprised if the other major tool-sets don't offer something similar) Disclaimer: JetBrains sponsor our local PUG-meetings with a door-prize. -- -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: path to python in venv
On 2023-09-27 20:32:25 -, Jon Ribbens via Python-list wrote: > On 2023-09-27, Larry Martell wrote: > > On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via > > Python-list wrote: > >> On 2023-09-27, Larry Martell wrote: > >> > lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> > >> > python3 > >> > lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> > >> > /usr/bin/python3 [...] > I'm a bit surprised your symlinks are as shown above though - mine > link from python to python3.11 to /usr/bin/python3.11, so it wouldn't > change the version of python used even if I installed a different > system python version. That's probably because you created the venvs with "python3.11 -m venv ...". The symlink points to the command you used to create it: % python3 -m venv venv % ll venv/bin/python* lrwxrwxrwx 1 hjp hjp 7 Aug 29 2022 venv/bin/python -> python3* lrwxrwxrwx 1 hjp hjp 12 Aug 29 2022 venv/bin/python3 -> /bin/python3* lrwxrwxrwx 1 hjp hjp 7 Aug 29 2022 venv/bin/python3.10 -> python3* % python3.10 -m venv venv % ll venv/bin/python* lrwxrwxrwx 1 hjp hjp 10 Sep 28 00:45 venv/bin/python -> python3.10* lrwxrwxrwx 1 hjp hjp 10 Sep 28 00:45 venv/bin/python3 -> python3.10* lrwxrwxrwx 1 hjp hjp 15 Sep 28 00:45 venv/bin/python3.10 -> /bin/python3.10* hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | [email protected] |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: path to python in venv
On 9/27/2023 2:53 PM, Larry Martell via Python-list wrote: I was under the impression that in a venv the python used would be in the venv's bin dir. But in my venvs I see this in the bin dirs: lrwxrwxrwx 1 larrymartell larrymartell7 Sep 27 11:21 python -> python3 lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> /usr/bin/python3 Googling this I read: The presence of symbolic links like python and python3 in the bin directory of your virtual environment pointing to the system Python executable (/usr/bin/python) suggests that the virtual environment was created using the system Python interpreter rather than a standalone Python installation. This can happen if you create a virtual environment using a system-wide Python interpreter, and the virtual environment inherits some of the symbolic links or shortcuts from the system Python installation. In this case, your virtual environment is not fully isolated because it still relies on the system Python interpreter. Not sure what this really means, nor how to get python to be in my venv. You don't need to "get python to be in my venv". The venv contains its own Python Lib directory, and whatever site-packages installs you want for that venv. In essence, the script for launching the venv sets up the PYTHONPATH variable and some other paths so that Python finds its files in the venv directories instead of in the usual Python locations. Setting these paths may involve creating symbolic links and that is all done for you. The thing you need to appreciate is that when you create a venv with a command like this: -m venv path/to/venv this will all link back to whatever version of Python you used in place of . If you invoked it with python3, on Linux you will get whatever your system runs when you type "python3", which would usually be the system's Python install. If you want to use some other version of Python, say python3.10, then just run that one instead when you create the venv. -- https://mail.python.org/mailman/listinfo/python-list
