您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

我可以将Python Windows软件包安装到virtualenvs吗?

我可以将Python Windows软件包安装到virtualenvs吗?

我最终改编了一个脚本(http://effbot.org/zone/python- register.htm)以在注册表中注册Python安装。我可以选择Python作为注册表中 Python,运行Windows安装程序,然后重新设置注册表:

# -*- encoding: utf-8 -*-
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# Adapted by Ned Batchelder from a script
# written by Joakim Löw for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix

regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
    installpath, installpath, installpath
)

def RegisterPy():
    try:
        reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
    except EnvironmentError:
        try:
            reg = CreateKey(HKEY_LOCAL_MACHINE, regpath)
        except Exception, e:
            print "*** Unable to register: %s" % e
            return

    SetValue(reg, installkey, REG_SZ, installpath)
    SetValue(reg, pythonkey, REG_SZ, pythonpath)
    CloseKey(reg)
    print "--- Python %s at %s is Now registered!" % (version, installpath)

if __name__ == "__main__":
    RegisterPy()

使用您要注册的Python运行此脚本,它将被输入到注册表中。请注意,在Windows 7和Vista上,您需要具有管理员权限。

python 2022/1/1 18:16:22 有680人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶