简体   繁体   English

将python的默认版本从32位更改为64位

[英]Change default version of python from 32bit to 64bit

I am attempting to switch over my default python.exe from 32bit to 64bit.我试图将我的默认 python.exe 从 32 位切换到 64 位。 the first time i downloaded and installed python i downloaded the 32bit version.我第一次下载并安装 python 时,我下载了 32 位版本。 I later found in the project i am currently working on, that I need a 64bit version of python in order for everything to be compatible.后来我在我目前正在处理的项目中发现,我需要一个 64 位版本的 python 才能使所有内容兼容。 I have uninstalled the 32bit version but and installed the 64bit version.我已经卸载了 32 位版本,但安装了 64 位版本。

prior to uninstalling the 32bit version i could check my version by typing: python --version into the command prompt, however now that the 32bit version is uninstalled and the 64bit version is installed this command no longer works.在卸载 32 位版本之前,我可以通过在命令提示符中键入: python --version来检查我的版本,但是现在卸载了 32 位版本并安装了 64 位版本,此命令不再有效。 I have noticed that some files pretaining to the 32bit version are still there (looks like packages that were previously installed using pip)我注意到一些 32 位版本的文件仍然存在(看起来像以前使用 pip 安装的包)

i have verified the the environment variables (PATH) are properly set for the 64bit python version yet it is still not registering.我已经验证为 64 位 python 版本正确设置了环境变量 (PATH),但它仍然没有注册。

when i type python --version now it yields: 'python' is not recognized as an internal or external command, operable program or batch file.当我现在输入python --version它会产生: 'python' is not recognized as an internal or external command, operable program or batch file.

but i am able to run a pythonApp.py with this as its body:但我能够以它为主体运行 pythonApp.py:

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

import sys
import struct

print( 8 * struct.calcsize("P"))
print(sys.maxsize)

which yields:产生:

64
9223372036854775807

So i know i am able to run the 64bit python but i am unable to use it from cmd prompt as expected, including when attempting to use the pip.所以我知道我能够运行 64 位 python,但我无法按预期从 cmd 提示符使用它,包括尝试使用 pip 时。

update -- I found a quick fix for this: this solution will not work if you want to keep both versions and interchange them .更新 - 我找到了一个快速解决方案如果您想保留两个版本并互换它们,此解决方案将不起作用 but if you only need one, simply uninstall both (Start clean) and then install the version you want to be defaulted first.但如果您只需要一个,只需卸载两个(开始清理),然后先安装您想要默认的版本。

simple answer:简单的回答:

make sure you install the bit version you want first.确保先安装所需的位版本。

If you have already installed the 32bit version and want to switch to 64bit version then simply uninstall the 32bit version first then install the 64bit version.如果您已经安装了 32 位版本并想切换到 64 位版本,那么只需先卸载 32 位版本,然后安装 64 位版本。 Not sure if it was required but i also restarted the pc.不确定是否需要,但我也重新启动了电脑。

For me it was the other way around: I installed the 64bit version first and then the 32bit version but it still defaulted to the 32bit one.对我来说,情况正好相反:我先安装了 64 位版本,然后安装了 32 位版本,但它仍然默认为 32 位版本。

There is a way to fix this and keep both versions , at least for Windows 10:有一种方法可以解决此问题并保留两个版本,至少对于 Windows 10:

Both versions should have created two entries each in the PATH environment variable, with Python 3.9.1 they look like this for me:两个版本都应该在PATH环境变量中分别创建两个条目,对于 Python 3.9.1,它们对我来说是这样的:

C:\Program Files (x86)\Python\Python39-32\
C:\Program Files (x86)\Python\Python39-32\Scripts\
C:\Program Files\Python\Python39\
C:\Program Files\Python\Python39\Scripts\

It seems like whatever is at the top of the list is used first, so simply use the "Move Up" button to move the 64bit above the 32bit version.似乎首先使用列表顶部的任何内容,因此只需使用“向上移动”按钮将 64 位移动到 32 位版本之上。 Afterwards it should default to the 64bit version.之后它应该默认为 64 位版本。

You can still use the 32bit version with:您仍然可以使用 32 位版本:

"C:\Program Files (x86)\Python\Python39-32\python.exe" somecommand

The quotes are required because of the spaces in the path.由于路径中有空格,需要引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Python 更改 32 位 - > 64 位后让 Jupyter 工作 - How to get Jupyter working after Python change 32bit -> 64bit 在执行中从64位python.exe切换到32位 - Switching from 64bit python.exe to 32bit in mid execution 如何让 pip install 将软件包安装到 64 位版本,而不是 32 位版本? - How to get pip install to install packages into the 64bit version ,not 32bit one? Python 版本从 32 位到 64 位 - Python Version from 32 bit to 64 bit 如何在 anaconda 64bit 旁边安装 python 32bit - How to install python 32bit alongside anaconda 64bit 64位Python可以连接32位MS访问驱动程序吗? - Possible for 64bit Python to connect with 32bit MS access driver? 使用多个 Python 引擎(32Bit/64bit 和 2.7/3.5) - Using multiple Python engines (32Bit/64bit and 2.7/3.5) Windows 64位Ctypes模块上的Python 32位模块错误 - Python 32bit on Windows 64bit Ctypes module error 尝试在Windows 7 64位(Python 3.4.4 32位)上使用GDAL时出现“ ImportError:DLL加载失败” - “ImportError: DLL load failed” when trying to use GDAL on Windows 7 64bit (Python 3.4.4 32bit) 适用于32位python(3.6)的32位pyodbc可与Microsoft的64位odbc驱动程序配合使用。 为什么? - 32bit pyodbc for 32bit python (3.6) works with microsoft's 64 bit odbc driver. Why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM