无法加载“ .... *。ps1”,因为此系统上禁用了运行脚本

时间:2020-06-11 23:29:55

标签: visual-studio-code python-venv executionpolicy

这似乎是一个常见问题,但是我无法用现有帖子解决问题。我正在尝试为我的python项目创建一个虚拟环境。 VS代码编辑器在创建venv之后立即尝试激活它。它在venv的脚本文件夹中使用了activate.ps1文件(我曾经手动使用过actvate.bat)。但是错误出现了。 我尝试通过以管理员身份在cmd中输入以下代码来解决我的问题:

from random import randint
"""This program will enable the user and computer to start a rock paper scissors game"""

options = ["ROCK", "PAPER", "SCISSORS"]

message = {"tie": "Yawn it's a tie!", "won": "Yay you won!", "lost": "Aww you lost!"}


def decide_winner(user_choice, computer_choice):
    print("You chose %s") % (user_choice)

    print("PC chose %s") % (computer_choice)

    if user_choice == computer_choice:
        print(message["tie"])  # tie

    # user - paper , pc = rock
    elif user_choice == options[1] and computer_choice == options[0]:
        print(message["won"])

    # user - scissor , pc = paper
    elif user_choice == options[2] and computer_choice == options[1]:
        print(message["won"])

    # user - rock , pc - scissors
    elif user_choice == options[0] and computer_choice == options[1]:
        print(message["won"])

    else:
        print("YOU LOSE!")


def play_RPS():
    user_choice = input("Enter Rock, Paper, Scissors: ")

    computer_choice = options[randint(0,2)]
    decide_winner(user_choice, computer_choice)

play_RPS()

但是它说:

'Set-ExecutionPolicy'不被识别为内部或外部命令, 可操作的程序或批处理文件。

我不知道还能做什么。我只是自己使用了activated.bat,而且我认为它起作用了。但这对我来说有点烦。感谢您的帮助。

0 个答案:

没有答案
相关问题