{"id":19130556,"url":"https://github.com/adamdriscoll/snek","last_synced_at":"2025-10-27T12:17:18.611Z","repository":{"id":41125089,"uuid":"116183821","full_name":"adamdriscoll/snek","owner":"adamdriscoll","description":"PowerShell wrapper around Python for .NET  to invoke Python from PowerShell","archived":false,"fork":false,"pushed_at":"2023-12-15T16:04:59.000Z","size":433,"stargazers_count":139,"open_issues_count":4,"forks_count":13,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-15T03:54:47.857Z","etag":null,"topics":["hacktoberfest","powershell","python"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamdriscoll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-03T21:31:06.000Z","updated_at":"2025-02-13T18:42:30.000Z","dependencies_parsed_at":"2024-11-16T10:04:32.294Z","dependency_job_id":null,"html_url":"https://github.com/adamdriscoll/snek","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fsnek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fsnek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fsnek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fsnek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamdriscoll","download_url":"https://codeload.github.com/adamdriscoll/snek/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003954,"owners_count":21196794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","powershell","python"],"created_at":"2024-11-09T06:11:38.471Z","updated_at":"2025-10-27T12:17:18.511Z","avatar_url":"https://github.com/adamdriscoll.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Snek](https://www.reddit.com/r/Snek/)\n\n## PowerShell wrapper around [Python for .NET ](https://github.com/pythonnet/pythonnet) to invoke Python from PowerShell\n\n![](./snek.jpg)\n\n## Install snek \n\n```\nInstall-Module snek\n```\n\n## Requirements\n\n* Python v3.7, v3.8, v3.9, v3.10, or v3.11 (defaults to python 3.11)\n\n## Functions \n\n* Use-Python\n* Invoke-Python\n* Import-PythonRuntime\n* Import-PythonPackage\n* Install-PythonPackage\n* Uninstall-PythonPackage\n* Use-PythonScope\n* Set-PythonVariable\n\n### Invoke Python Code (v3.11)\n\n```\nUse-Python { \n    Invoke-Python -Code \"print('hi!')\" \n}\n    \nhi!\n```\n\n### Invoke Python Code (v3.7)\n\n```\nPS \u003e Use-Python { \n    Invoke-Python -Code \"print('hi!')\" \n} -Version v3.7\n    \nhi!\n```\n\n### Returning A Value from Python to PowerShell\n\nDue to the use of `dynamic` the type must be cast to the expected type so you need to specify the `-ReturnType` parameter to do so.\n\n```\nUse-Python {\n    Invoke-Python \"'Hello'\" -ReturnType ([String])\n}\n```\n\n### Imports the `numpy` Python module and does some math\n\nAccess methods of modules directly! \n\n```\nUse-Python {\n    $np = Import-PythonPackage \"numpy\"\n    [float]$np.cos($np.pi * 2)\n\n    [float]$np.sin(5)\n    [float]($np.cos(5) + $np.sin(5))\n} -Version v3.7\n```\n\nOutput\n\n```\n1\n-0.9589243\n-0.6752621\n```\n\n### Manage pip\n\nFormat is `Install-PythonPackage \u003cpackage\u003e`\n\n```\nInstall-PythonPackage requests\n```\n\nOr similarly:\n\n```\nUninstall-PythonPackage requests\n```\n\n### Using Scopes\n\nYou can use Python scopes to string together multiple `Invoke-Python` calls or to pass in variables from PowerShell. \n\n```\nUse-Python {\n    Use-PythonScope {\n        Invoke-Python -Code \"import sys\" \n        Invoke-Python -Code \"sys.version\" -ReturnType ([string]) \n    }\n}\n```\n\n### Passing a .NET Object to Python\n\n```\nclass Person {\n    [string]$FirstName\n    [string]$LastName\n}\n\nUse-Python {\n    Use-PythonScope {\n        $Person = [Person]::new()\n        $Person.FirstName = \"Adam\"\n        $Person.LastName = \"Driscoll\"\n        Set-PythonVariable -Name \"person\" -Value $Person\n\n        Invoke-Python -Code \"person.FirstName + ' ' + person.LastName\" -ReturnType ([string])\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamdriscoll%2Fsnek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamdriscoll%2Fsnek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamdriscoll%2Fsnek/lists"}