在 Windows 上安装 Python 3.6 的路径是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44749636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What path to install Python 3.6 to on Windows?
提问by boot4life
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?
3.6 安装程序建议C:\Users\MyUserName\AppData\Local\Programs\Python\Python36-32
与 Windows 上的任何其他软件不同。我记得安装的早期版本C:\PythonXY
在 Windows 上也很不寻常。这些真的是个好主意吗?
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%
.
特别是,我不明白为什么我只想为我的用户帐户安装它。复选框“为所有用户安装启动器(推荐)”是默认选中的,这似乎与安装到%APPDATA%
.
What is a good path to install Python to?
安装 Python 的好方法是什么?
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.
我是一个完整的 Python 业余爱好者,我不想给自己带来问题。例如,我害怕在路径中添加空格。
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.
进一步单击安装程序,发现有一个复选框可供所有用户安装。这会立即设置Program Files (x86)
复选框的基本路径。
采纳答案by TrakJohnson
This is a very subjective question in most cases, I'm not really sure if its even fit for SO.
在大多数情况下,这是一个非常主观的问题,我不确定它是否适合 SO。
Here are the different characteristics of each path:
以下是每个路径的不同特征:
C:\PythonXY
:
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
orconda envs
solves this problem) Program Files
is the same, except that there are spaces in the path (probably a bad idea)
- 需要管理员权限
- 所有用户都可以访问它——如果你只想在你的系统上安装一个 python 版本,那就更好了
- 在命令行中编写更实用(多个python安装可能需要,尽管使用
venvs
或conda envs
解决了这个问题) Program Files
是一样的,只是路径中有空格(可能是个坏主意)
AppData
:
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.
我拥有管理员权限并且是我计算机上的唯一用户,所以我选择了第一个选项,但它确实取决于大小写。
EDITPlease see the comments below for rectifications on paths.
编辑请参阅下面的评论以纠正路径。
回答by JDMorganArkansas
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."
由于 Windows 10 的新“安全功能”,在 64 位 Windows 10 中的 c:\Program Files\ 中安装 Python 会出现问题。 c:\Programs Files\ 的子文件夹对其权限受限,与安装过程不兼容对于一些 Python 包。安装在根目录正下方的目录中(例如 c:\Python36\ for Python 3.6)可以避免这些问题。它可能“不太安全”,但它确实有效,在 c:\Program Files\ 下安装有时不会。比如我发现如果在安装在c:\Program Files\下的Python 3.7中尝试安装matplotlib包,matplotlib依赖的一些包会被阻止安装,该包不会运行,但是如果它安装在 c:\Python37\ 中,运行良好。
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.
如果您是唯一要使用 Python 的人,那么为单个用户在 %appdata% 文件夹中安装是可以的,但是如果您的计算机将被另一个用户使用(例如,如果它是一台工作计算机,将被接管您职位的新员工“继承”),则必须为该用户重新安装 Python(以及所有必要的 Python 包)。
回答by Kartik Podugu
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.
我认为安装 python 的最佳路径是C:\Users\<Username>\PythonXX
(特别是如果您使用多个用户的 PC 并且您使用的是组织 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.
如果您安装到C:\PythonXX
或C:\Program Files\PythonXX
,您将始终遇到权限问题。一旦您尝试使用“pip install”安装某些软件包/库,权限将不允许安装这些软件包。
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.
如果您C:\Users\<Username>\AppData\Local\Programs\Python\PythonXX
按照python安装程序的建议继续安装,它也没有任何权限问题,但路径不太容易记住。
Few more important points:
更重要的几点:
- 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. - Always check the option, add python path to Path variable during installation, so that you can also use python from command prompt/powershell.
- Always check the option, install pip, so that you can use pip to install/update packages/libraries.
- 如果您使用的是个人笔记本电脑并且您是唯一的用户(您也是管理员),那么安装 python
C:\PythonXX
也是一个最佳选择。 - 始终选中该选项,在安装过程中将 python 路径添加到 Path 变量,以便您也可以从命令提示符/powershell 使用 python。
- 始终选中安装 pip 选项,以便您可以使用 pip 安装/更新包/库。