What path to install Python 3.6 to on Windows?
Asked Answered
E

4

50

The 3.6 installer suggests C:\Users\MyUserName\AppData\Local\Programs\Python\Python36-32 which is unlike any other software on Windows. I remember that earlier versions installed to C:\PythonXY which is also unusual on Windows. Is any of that really a good idea?

In particular, I don't see why I would want to install this only for my user account. The checkbox "Install launcher for all users (recommended)" is default checked which seems incompatible with installing into %APPDATA%.

What is a good path to install Python to?

I'm a complete Python amateur and I don't want to cause myself problems. I am fearful of adding a space to the path for example.


Clicking further through the installer it turns out there is a checkbox to install for all users. This immediately sets a Program Files (x86) based path to the checkbox.

enter image description here

Expositor answered 25/6, 2017 at 19:8 Comment(2)
I finally find it at C:\Users\username\AppData\Local\Programs.(windows 10)Emarginate
See this tutorial for the recommended installation process for official Python: youtu.be/PUFnDSdk1jQ. The tutorial also covers the (automatic) path setting so that you don't have the problem in the first place.Sueannsuede
A
31

This is a very subjective question in most cases, I'm not really sure if its even fit for SO.

Here are the different characteristics of each path:

C:\PythonXY:

  • Requires administrator rights
  • All users have access to it - better if you want only one install of a python version on your system
  • More practical to write in command line (might be needed for multiple python installs, although using venvs or conda envs solves this problem)
  • Program Files is the same, except that there are spaces in the path (probably a bad idea)

AppData:

  • Doesn't require administrator rights
  • Only for one user - good if the other users don't want/need it
  • Might be painful to write in command line

I have admin rights and am the only user on my computer, so I chose the first option, but it really is case-dependent.

EDIT Please see the comments below for rectifications on paths.

Antebi answered 25/6, 2017 at 19:11 Comment(2)
Any authenticated user is allowed to create and modify a directory in the root of the system drive. That's the problem; it isn't secure. So for 3.5+ %ProgramFiles% is the default for all-user installations. The spaces in this directory for some locales aren't a problem; code that can't handle them has a bug that needs to be fixed. From the command-line you can use the py.exe launcher to run any installed version, but if you're developing for multiple versions across multiple projects you should really think about using virtual environments.Fencible
A per-user install of Python defaults to %LocalAppData%\Programs, which is the known shell folder FOLDERID_UserProgramFiles. Using the user's roaming %AppData% would lead to network congestion if roaming profiles are in use. As far as command-line difficulties with typing this path, there's the py launcher and PATH environment variable, plus venv virtual environments that can be created wherever you want for convenience.Fencible
H
2

Installing Python in c:\Program Files\ in 64-bit Windows 10 has problems because of the new "security features" of Windows 10. Subfolders of c:\Programs Files\ have restricted permissions on them which are not compatible with the installation processes for some Python packages. Installing in a directory directly below the root (for example c:\Python36\ for Python 3.6) avoids these problems. It may be "less secure", but it actually works, which installing under c:\Program Files\ sometimes does not. For example, I have found that if you try to install the matplotlib package in Python 3.7 installed under c:\Program Files\, some of the packages that matplotlib is dependent on are blocked from installing, and the package will not run, but if it is installed in c:\Python37\, it runs fine. Another example of overly enthusiastic Microsoft "security."

Installing in the %appdata% folder for a single user is fine if you are the only person who is going to be using Python, but if your computer is going to be used by another user (for example, if it is a work computer which will be "inherited" by a new employee that takes over your position), Python (and all necessary Python packages) would have to be reinstalled for that user.

Hilde answered 18/5, 2020 at 15:58 Comment(0)
D
2

I think the best path to install python is in C:\Users\<Username>\PythonXX (especially if you are using PC with multiple users and also if you are using your organization PC.

If you install to C:\PythonXX or to C:\Program Files\PythonXX, you will always have permissions issue. As soon as you try to install some packages/libraries using 'pip install ', permissions will not allow to install the packages.

If you leave the installation to be continued in C:\Users\<Username>\AppData\Local\Programs\Python\PythonXX as suggested by python installer, which also doesn't have any permissions issue, but path is not so easy to remember.

Few more important points:

  1. If you are using a personal laptop and you are the only user (you will be administrator as well), then installing python to C:\PythonXX is also a best option.
  2. Always check the option, add python path to Path variable during installation, so that you can also use python from command prompt/powershell.
  3. Always check the option, install pip, so that you can use pip to install/update packages/libraries.
Damning answered 28/5, 2020 at 19:16 Comment(0)
B
0

In my case because the Path variable was already set, I would only go to the python shell and type:

import os
os.path
Buttocks answered 16/12, 2021 at 8:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.