Error using CLI

When I try to run the CLI script I get the following error:
Microsoft Windows [Version 10.0.19041.1237]
(c) Microsoft Corporation. All rights reserved.

C:\windows\system32>powershell -Command “& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString(‘https://platform.activestate.com/dl/cli/pdli01/install-latest.ps1’))) -c’state activate --default bvernham/ActivePython-3.8-2’”
New-Object : Cannot create type. Only core types are supported in this language mode.
At line:1 char:28

  • & $([scriptblock]::Create((New-Object Net.WebClient).DownloadString(’ …
  •                        ~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : PermissionDenied: (:slight_smile: [New-Object], PSNotSupportedException
    • FullyQualifiedErrorId : CannotCreateTypeConstrainedLanguage,Microsoft.PowerShell.Commands.NewObjectCommand

The expression after ‘&’ in a pipeline element produced an object that was not valid. It must result in a command
name, a script block, or a CommandInfo object.
At line:1 char:3

  • & $([scriptblock]::Create((New-Object Net.WebClient).DownloadString(’ …
  • + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression
    
    
    

C:\windows\system32>

Tried multiple versions.

I ran as adminstrator.

Any ideas?

Don’t run this as Administrator. It does not install the way you’re thinking it will. This install command will give you a virtual runtime, suitable for doing Python coding.

You might want a different installation command, or your use case might require an older version of Python for older versions of Windows.

If you’re on Windows Server 2016, see the forum posts for configuring your version of Powershell to support TLS 1.2, which it will not do out of the box. You may also need to set variable that allow the command line to get out past your firewall or proxy server.

I am doing what is says in the ActiveState website to install ActivePython.

"Install via Command Line
Run the following command in the Command Prompt (cmd.exe)
powershell -Command “& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString(‘https://platform.activestate.com/dl/cli/pdli01/install-latest.ps1’))) -c’state activate --default bvernham/Python-3.9.9-Windows’”

This command installs the State Tool package manager, which then intalls lets you manage your runtime. Find tips on managing your runtime in the CLI with our State Tool Cheat Sheet"

This say it installs the “State Tool” but I can not even to this.

Which version of Windows are you running on?

Windowns 10 pro.
Intel(R) Xeon(R) E-2276M CPU @ 2.80GHz 2.81 GHz
32.0 GB (31.7 GB usable)
64-bit operating system, x64-based processor
Windows 10 Pro
Version 2004
Install date 5/17/2021
build 19041.1237
Windows Feature Experience Pack 120.2212.3530.0

Trying installing just the State Tool. Open a cmd.exe window as your normal userID, and enter this:
powershell -Command “& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString(‘https://platform.activestate.com/dl/cli/install.ps1’)))”

I tried that and I get the same exact error.

New-Object : Cannot create type. Only core types are supported in this language mode.
At line:1 char:28

  • & $([scriptblock]::Create((New-Object Net.WebClient).DownloadString(’ …
  • CategoryInfo : PermissionDenied: (:slight_smile: [New-Object], PSNotSupportedException
  • FullyQualifiedErrorId : CannotCreateTypeConstrainedLanguage,Microsoft.PowerShell.Commands.NewObjectCommand
    The expression after ‘&’ in a pipeline element produced an object that was not valid. It must result in a command
    name, a script block, or a CommandInfo object.
    At line:1 char:3
  • & $([scriptblock]::Create((New-Object Net.WebClient).DownloadString(’ …
  • CategoryInfo : InvalidOperation: (:slight_smile: , RuntimeException
  • FullyQualifiedErrorId : BadExpression

Thanks

That at least isolates the problem a bit more. It looks like you have GPO set which is forcing Powershell into Constrained Language Mode. Can you find that and turn it off? Or find a way to start it in full language mode?