0

I had my previous python3.7 installed by Anaconda and then I installed python3.9 using homebrew. Then things really messed up. When I check my packages using pip3 list, it shows no packages installed. I suppose it was sourcing the site-packages under python3.9. However, when I run python in terminal (which python3), it showed that I was still running the old python3.7 which had all my packages. The problem is whenever I installed new packages, it didn't work because I was still running the old python3.7 while new packages were installed to python3.9.

Question:

  1. How can I make my python version consistent, e.g. I only want to use one python and preferably the later version --python3.9.
  2. How should I manage my packages. There are a lot of them and I really don't want to install every single one again on python3.9

Thank you very much!

JackeyOL
  • 313
  • 2
  • 16

1 Answers1

1

Make a list of your pip installed pacakages:

pip3 freeze > my_packages.txt

Uninstall python3.7:

sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.7

With your new install of python3.9, install the previous packages:

pip3 install -r my_packages.txt
Dharman
  • 30,962
  • 25
  • 85
  • 135
Insula
  • 999
  • 4
  • 10
  • Thank you for your answer. For the 1st step, however, I wasn't able to make a list of my previous pip3 packages. What should I do about that? – JackeyOL Jan 17 '21 at 18:12
  • type "pip list -o" into your terminal. You should get some packages. I found this [link](https://stackoverflow.com/questions/739993/how-can-i-get-a-list-of-locally-installed-python-modules) what may help you. – Insula Jan 17 '21 at 18:24
  • This is what I got with `pip3 list -o`: ```idna 2.10 3.1 wheel setuptools 51.0.0 51.3.1 wheel wheel 0.36.1 0.36.2 wheel``` – JackeyOL Jan 17 '21 at 18:42
  • I take it that's not all your packages? If it isn't I don't particularly know what's wrong. Did you mess with or delete anything? – Insula Jan 17 '21 at 20:33
  • Right. I'm missing my packages. I suppose the problem is a linking problem because I have pythons installed by anaconda and homebrew. For some reasons, the default python3 is still the anaconda python3.7 but the pip3 is using pip3.9 and there isn't any packages installed under that site-packages directory. – JackeyOL Jan 17 '21 at 21:12
  • Did you install the packages through pip and in your terminal? The paths have probably messed up. I always recommend to use virtual environments in python, so you're packages stay with your projects. I also found this code online what could help you: /usr/local/bin/python3.7 -m pi. Other than that I think you might just need to reinstall all your packages mate – Insula Jan 17 '21 at 21:54
  • Yes I installed all my packages using pip. What does this line of code do? – JackeyOL Jan 18 '21 at 22:11
  • What code are you referring to, sorry? Also if your question is solved, please accept an answer. Thanks. – Insula Jan 18 '21 at 22:17
  • /usr/local/bin/python3.7 -m pi – JackeyOL Jan 18 '21 at 23:14
  • I think I typed the wrong code and thought I was answering a different question, just ignore that code, apologies :) – Insula Jan 18 '21 at 23:20