如何设置python路径并在powershell链接_如何将Python 3.3添加到Powershell?

Hey I've been trying to add Python 3.3 to windows powershell by repacing 27 with 33 in the path.

I tried to post a screenshot but turns out I need 10 rep so I'll just copy and paste what I've attempted:

[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33", "User")

>

[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33")

>

[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33\python.exe", "User")

>

[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33;C:\Python33\Scripts", "User")

>

[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33\", "User")

The path to the folder where python.exe resides is: C:\Python33

Somewhere I'm doing something wrong but am not sure where.

Help a fellow out with his foray into programming?

Thanks.

解决方案

Python 3.3 comes with PyLauncher (py.exe), which is installed in the C:\Windows directory (already on the path) and enables any installed Python to be executed via command line as follows:

Windows PowerShell

Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\> py

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> ^Z

PS C:\> py -2

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> ^Z

PS C:\> py -3

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>>

Note that the default Python if both 2.X and 3.X are installed is 2.X (3.X in later versions of Python), but this can be overridden with the -3 switch or the default changed by setting the PY_PYTHON environment variable.

Also, if you install Python 3.3 last and register extensions, PyLauncher will be the default program for .py files and adding a special #! comment to to top of a script will specify the version of Python to use for the script. This allows you to have Python 2 and Python 3 files on the desktop and just double-click them to run the correct version of Python for that script.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值