-2

How would I install python3.9 in a custom or user-defined location?

Ideally if I say brew install python@3.9, python gets installed in /usr/local/bin/ but I need to have this installed in a different location. How would I do that?

I am able to change the path or choose the path while installing on Windows and not on Mac. Could someone please help me on this?

Yannis P.
  • 2,745
  • 1
  • 24
  • 39
  • This is possible if you downloaded the Python installer from https://www.python.org/downloads/ and specified the location you want it to be installed in the "Customize" screen you get from clicking on the "customize" button on the "Installation Type" screen when you install using the downloaded installer. – Hiran Hasanka Jan 05 '23 at 11:44
  • `pyenv` lets you install a number of Python versions in parallel and easily switch between them. – tripleee Jan 05 '23 at 12:07

2 Answers2

0

One of the solutions you can choose, is to install Anaconda. Anaconda should give you the step Destination Select, where you can select where to install the base enviroment, as can also be seen here. base will be where a Python version of your choice will be installed. You can later on add more versions in other environments as outlined in the comment of triplee

Yannis P.
  • 2,745
  • 1
  • 24
  • 39
0

The best* way to install Python in a custom location on your Mac is through a custom installation from the Official Python Site. Once you open up the package there is a step along the way that let's you choose where to install it (Destination Select).

From there, you can use virtualenv to control which version of Python you use.

*best as in most lightweight (don't need Anaconda), safest (from official site), and probably the easiest (GUI installer)

Install Python on a Mac Installer Screen

bujian
  • 152
  • 8