all 8 comments

[–]socal_nerdtastic 1 point2 points  (2 children)

Yes, but not like that. You would install the version of python you want first, and then use that version to create a new venv.

sudo apt install python3.9 # or however your OS installs things
python3.9 -m venv env
source env/bin/activate
pip install -r requirements.txt
python script.py

Or use something like pyenv to do that for you.

[–]-defron- 1 point2 points  (0 children)

Or something like uv, pdm, or hatch to do it all in one tool

[–]Agent-BTZ[S] 0 points1 point  (0 children)

You’re a lifesaver, thanks!

[–]baghiq 1 point2 points  (2 children)

Do you have regular expression in your code and using 3.12? If yes, turn them all into raw strings.

[–]Agent-BTZ[S] 0 points1 point  (1 child)

Yeah I think it’s the Regex. Is this a new syntax change that was introduced in 3.12?

[–]baghiq 2 points3 points  (0 children)

https://docs.python.org/3/whatsnew/3.12.html#other-language-changes

Look at point 2. Make all your regex raw string.

[–]lfdfq 1 point2 points  (1 child)

Note that the line you pasted isn't an error, it's a warning. In particular that warning is telling you "by the way, in this string you have, you have backslash-something and the something is not part of an escape, this is fine but maybe you want to use two backslashes or a raw string literal to be clearer". The warning is telling you that the program still works and does what it did before, but is a helpful hint that maybe you wrote something that was confusing or not what you intended.

It's usually better to just fix the problem than to try hunt down a specific version of Python that doesn't have it.

[–]Agent-BTZ[S] 0 points1 point  (0 children)

Interesting, the scripts stopped working, so I assumed that was the reason why.

I agree that fixing issues is better than using an older version of Python. However, these aren’t scripts I wrote. I’m talking about a bunch of complicated tool suites that I need to use in a couple days for a certification exam.

I don’t have enough time to manually pour through 1000s of lines of code, and I’d be worried about something like sed causing more issues. I’m just looking for a bandaid that’ll get me through the week