0

I am trying to copy modules from python 3.10 to 3.11. I am using windows 11.

  • My understanding is that one just downloads and install the new version of python.
  • I make sure that python is added to path.

i follow this instruction: copying modules from python 3.10 to 3.11

i then do this:

python3.10 -m pip freeze > requirements.txt
python3.11 -m pip install -r requirements.txt

but it throws an error message:

'python3.10' is not recognized as an internal or external command,
operable program or batch file.

So i do this:

where python

to get this:

C:\Users\admin\AppData\Local\Programs\Python\Python311\python.exe
C:\Users\admin\AppData\Local\Programs\Python\Python310\python.exe
C:\Users\admin\AppData\Local\Programs\Python\Python39\python.exe
C:\Users\admin\AppData\Local\Microsoft\WindowsApps\python.exe

I note the guidance here: https://pip.pypa.io/en/stable/cli/pip_freeze/ which states this:

env1\bin\python -m pip freeze > requirements.txt
env2\bin\python -m pip install -r requirements.txt

So my question is, with my paths and the above instruction, how do I implement the correct command so that all the packages are successfully updated in the new python version?

update:

is this the correct implementation ?

C:\Users\admin\AppData\Local\Programs\Python\Python310\python -m pip freeze > requirements.txt
C:\Users\admin\AppData\Local\Programs\Python\Python311\python -m install -r requirements.txt

And if so do i need to copy the requirements.txt file to the new path ?

D.L
  • 4,339
  • 5
  • 22
  • 45
  • 1
    _is this the correct implementation ?_, yes seems fine. – Maurice Meyer Feb 05 '23 at 19:27
  • I'm failing to understand why you don't just install the 3.11 modules properly instead of hoping the 3.10 ones might work? – Mark Setchell Feb 05 '23 at 19:47
  • @MarkSetchell, because I have many running apps that rely on these and I want to make sure everything is there even if there is too much. (i can do upgrades later if needed). – D.L Feb 05 '23 at 19:50
  • [\[SO\]: How to install a package for a specific Python version on Windows 10? (@CristiFati's answer)](https://stackoverflow.com/a/57883242/4788546). – CristiFati Feb 05 '23 at 20:24

1 Answers1

1

You can specify full path of python,

C:\Users\admin\AppData\Local\Programs\Python\Python310\python.exe -m pip freeze > requirements.txt
C:\Users\admin\AppData\Local\Programs\Python\Python311\python.exe -m pip install -r requirements.txt

or It would be better for you to create a link for python in the same directory,

cd C:\Users\admin\AppData\Local\Programs\Python\
mklink Python310\python3.10.exe Python310\python.exe
mklink Python311\python3.11.exe Python311\python.exe

Later on when you want to use python3.xx, just type python3.xx it will work. Now you can use the same command you are using.

  • with the first method, would i need to copy the `requirements.txt` file to the new path ? – D.L Feb 05 '23 at 19:37
  • You can run it from anywhere, since `requirements.txt` will be created in the folder you run from, same will be used while installing package for python3.11. – Lokesh Kurre Feb 05 '23 at 19:42
  • so the `requirements.txt` file would exist in whatever folder the command was run from. So a standard `windows11` command prompt opens here `C:\Users\admin` and this is where the `requirements.txt` would exist ? – D.L Feb 05 '23 at 19:48
  • When you run first command containing `> requirements.txt` this will create the file in the directory its run from. And for running 2nd command, you need the `requirements.txt`. – Lokesh Kurre Feb 05 '23 at 19:50
  • much appreciated. i have marked this as the correct answer and upvoted.... no doubt i will be revisiting at `3.12`. – D.L Feb 05 '23 at 19:51