Uninstalling Python 3.10

I am trying to figure out how to go about uninstalling Python 3.10. on my computer which is a Mac OS Big Sur laptop (Version 11.6.2).

I am ultimately trying to install PyTorch on my laptop, but I was having trouble trying to install it via Python 3.10.

Would it be advisable to uninstall Python 3.10 on my computer by going to the terminal and entering the following command?

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

Maybe a better approach would be to create a new virtual environment (e.g. via conda) and install Python=3.9 there while leaving the system 3.10 installation intact.

Thanks very much for your reply. I just have one final question for now, how to go about exactly installing Python 3.9 via conda?

Once conda is installed create a new env via:

conda create -n env_name python=3.9
conda activate env_name

This will install a new virtual environment with Python 3.9 and activate it afterwards. You could then install PyTorch into this environment.

I’m really sorry, but I am still having a little trouble with this issue. I have followed your advice of installing conda and I got a message at the end saying that the installation was completed successfully. However, when I go into the terminal to confirm that conda has been installed correctly, it says command not found.

Maybe the Getting Started Guide from conda could be helpful to get familiar with its usage and the virtual envs.

Another method would be using pyenv.

You can easily manage different versions of python. Once you install pyenv,

pyenv install 3.9.9.   # python version you'd like to install

And set that version as global

pyenv global 3.9.9

Then you can use python with desired version.

I am currently working on Mac Monetery and work as charm.

Did you use terminal to install pyenv on your Mac?

Yes I am using in terminal.

Here is the process that I used:

Install pyenv using homebrew.

brew update
brew install pyenv

After the installation, you need to set up bash environment. Since macOS uses zsh, you need to update .zshrc and .zprofile files as suggested in the GitHub page:

echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

Now, you can install any version python using pyenv:

pyenv install 3.9.9

And after that, set as global.

I usually setup virtual environment but it is your choice.

Hope this can help you.

Thanks for all your help so far. I have been able to install PyTorch on my mac with your instructions, but there is just one more query I have: After installing PyTorch, how do you actually go about using PyTorch to create Deep Learning models? There are several packages that PyTorch comes installed with, so where do you go from here?

Check the tutorial pages in the PyTorch website: Welcome to PyTorch Tutorials — PyTorch Tutorials 1.10.1+cu102 documentation

Coding process with PyTorch is just like a normal python coding.

PS: if you want to use tensorboard to log and/or visualise learning process, currently there is a bit of problem due to a version of disutil package. Check this issue: https://github.com/pytorch/pytorch/issues/69894

Thanks I’ll definitely take a look at these tutorial pages, but which files in the Pytorch package do you click on to start a deep learning environment? Particularly, a deep learning environment for computer vision?

I am a bit lost. Why are you asking for clicking something on to start a deep learning environment?

As far as I know, PyTorch is a library. Thus, just like another python package, you import and use their function/modules in your python code.

If you are talking about docker environment, then this will be another topic.

If you are asking about using pre-trained model, then you probably can find tutorials how to load and use them.

Correct me if you are talking about different things.

I’m sorry I’m still a little new to python. So PyTorch comes installed with the following files:

How do you launch the Python shell for doing the actual coding?

At this point, I am not sure your question is relevant to the topic. Looks like your problem is more about python in general.

Anyway, I don’t know which directory you are showing on the picture but let me guess that is in venv/lib/python3.9/ (if you created virtual environment and installed package there. And of course guess you already activated the virtual environment)

In python, once a library is installed, you don’t need to open the code separately. Just create any file with the extension .py and import the library accordingly.

For example, if you want to use PyTorch, create following script.

# test.py

if __name__ == "__main__":
    import torch

    A = torch.rand(3, 3)  # create a 3 x 3 tensor with random numbers
    print(A) # print the tensor

And run the code in the terminal

python test.py # I assume your default python version is 3 not 2.

In this way, you can use any function/module provided by PyTorch.

If you want to test whether PyTorch is installed correctly or not, test in the terminal like this.

python -c "import torch; print(torch.__version__)"

If everything is correctly installed, you can see the version number of the PyTorch.

Hope this can answer some of your questions.

Thanks again for your reply. I’m sorry for all the questions, I just really want to get this right. You told me to test the following command in terminal:

python -c “import torch; print(torch.version)”

and I got a version number of 1.10.2, so it appears that PyTorch is installed on my mac. However, when I try to run the following code in terminal:

python test.py

I get an error message of can’t open file, No such file or directory.

You would have to create the test.py file first before trying to execute it.
As @kyoungseoun_chung explained, it might be helpful to check some Python tutorials first, e.g. this one (or search any [free] course) to get familiar with the programming language first.