I have python installed through windows store and I can install programs using pip, but when I try to run said programs, they fail to execute in powershell.
How can I make sure that the necessary "scripts" folder is in my path? I never faced these problems when installing from executable.
For example, "pip install ntfy" runs successfully in Powershell.
The command "ntfy send test" fails telling me the term is not part of a cmdlet, function, etc. etc.
The 'ntfy' program is located here /mnt/c/Users/vlouvet/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0/LocalCache/local-packages/Python37/Scripts/ntfy.exe
What is the recommended way of editing my path so that programs installed via pip are available across windows store updates of the Python language?
Python will be installed into the Program Files directory. The Python Launcher for Windows will be installed into the Windows directory.
For beginners who are new to Python, we recommend you install Python from the Microsoft Store. Installing via the Microsoft Store uses the basic Python3 interpreter, but handles set up of your PATH settings for the current user (avoiding the need for admin access), in addition to providing automatic updates.
In Windows, the PIP configuration file is %HOME%\pip\pip.ini. There is also a legacy per-user configuration file. The file is located at %APPDATA%\pip\pip.ini . You can set a custom path location for this config file using the environment variable PIP_CONFIG_FILE .
Key terms. pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers. A virtual environment is a semi-isolated Python environment that allows packages to be installed for use by a particular application, rather than being installed system wide.
I highly recommend you not to use python installed from the Windows Store, because you'll face such errors, and even more nasty ones.
Create a virtual environment on a more accessible folder, for example in C:\Users\<user>\python
. To do so, do the following:
cd
(Note that usually PowerShell already starts inside your user folder. This is an important setting to have, and if not, you should change your powershell starting point to this folder for the future.);mkdir python; cd python
;python -m venv venv
;ls
);./venv/Scripts/activate
;Now, you have fully created and activated a virtual environment for your current PowerShell session. You can now install any packages / programs using pip
.
After that, the only thing that you need to do is to add C:\Users\<user>\python\venv\Scripts
to your Path, and you're good to go.
By adding this folder to your Path, you may be using an outdated python version in the future, since the Scripts
folder inside your virtual environment also adds a python executable that will be enabled in the path.
As I stated before, I do not recommend to have the Microsoft Store version of python installed on your machine. That said, you're probably using it for the conveniences of having the latest Python version installed as soon as they're released. To alleviate this need while also getting rid of your MS Store Python. I recommend you using Chocolatey to install python (and pretty much any other programs for development).
What is Chocolatey?
Chocolatey is a package manager for Windows, pretty much like apt-get
for Ubuntu Linux or HomeBrew for MacOS. By using a package manager, you get rid of the hassle of always having to execute the (mostly annoying) install wizards on windows.
To install Chocolatey:
choco -v
in PowerShell;choco install python -y
. Let's break down this command:
choco install
-> The package installer of chocolateypython
-> the name of the package you want to install-y
-> This tells the installer to skip install verification by saying "Yes to All" scripts that will be executed in order to install a package.Hope I could help you!
The above answer is good but I managed to get it to work by doing the following.
C:\Users\"your user"\AppData\Local\Packages
it will be named something like PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0
Path
, click itC:\Users\"your user"\AppData\Local\Packages\"python install directory name from 1. here"\LocalCache\local-packages\Python37\Scripts
inside the little box under the last item in the listOn Windows you can find the user base binary directory by running
python -m site --user-site
and replacing site-packages with Scripts.
For example, this could return
C:\Users\Username\AppData\Roaming\Python36\site-packages
so you would need to set your PATH to include
C:\Users\Username\AppData\Roaming\Python36\Scripts
You can set your user PATH permanently in the Control Panel. You may need to log out for the PATH changes to take effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With