microsoft / service-fabric-cli

Service Fabric CLI Tools
Other
53 stars 52 forks source link

After Install via Windows Powershell, `sfctl` is not recognized #244

Open aaaronic opened 3 years ago

aaaronic commented 3 years ago

Background

I installed sfctl according to the documentation here: https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-cli

After install, sfctl is not recognized:

> sfctl
sfctl : The term 'sfctl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct  
and try again.

It clearly is a PATH issue of some sort and I see documentation about how to fix a similar issue on Linux / Mac, but I don't see similar information for Windows (in my case, 10). Here is the relevant information about my installation:

> pip show sfctl
Name: sfctl
Version: 11.1.0
Summary: Azure Service Fabric command line
Home-page: https://github.com/Azure/service-fabric-cli
Author: Microsoft Corporation
Author-email: sfpythoncli@microsoft.com
License: MIT
Location: c:\users\aaronhansen\appdata\roaming\python\python39\site-packages
Requires: sfmergeutility, portalocker, knack, tqdm, msrest, six, applicationinsights, psutil, adal, msrestazure, requests, azure-servicefabric, joblib, future
Required-by:
> pip -V
pip 21.1.1 from c:\program files (x86)\microsoft visual studio\shared\python39_64\lib\site-packages\pip (python 3.9)
> python -V
Python 3.9.5

I could see the issue being related to my pip/Python having been installed by Visual Studio, instead of the typical Python installation, but I imaging a lot of Windows developers might be in the same situation.

I found the sfctl site-package in C:\Users\me\AppData\Roaming\Python\Python39\site-packages, but it seems the "global" site-packages folder is C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\Lib\site-packages (since that's where pip is).

The Solution:

The solution was to add the following to my PATH: C:\Users\me\AppData\Roaming\Python\Python39\Scripts

If you see the following during installation on Windows, you might be in the same boat:

> pip install sfctl
Defaulting to user installation because normal site-packages is not writeable