Should the Python Windows Store package have a default virtual environment?

Background: I’m a Python novice, but an experienced Windows developer. The Python Windows store package seemed like a great way for me to learn, but I quickly ran into complex error messages that really left a lot to be desired (shown below); the problem was I ran a setup.py script which tried to write into C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3… One of the explicit suggestions in the error message was to log into an administrator account, which goes against windows best practices, especially for a package targeted at beginner/educational use.

After a bit of digging, I found that a virtual environments may be general Python solution, but virtual environments are not exactly documented as a beginner feature. It seems to me that if the Microsoft Store package somehow sets up a virtual environment (or something like it, e.g. by defining an environment variable) in a user-specific directory, this sort of message could be avoided. Does this make sense?

Or perhaps there’s a simpler way, e.g. defining a environment variable pointing to a per-user directory. Would this be PYTHON_PATH?

Repro

  • Install Python 3.9 from the windows store
  • clone github/BurtHarris/pcbflow.git
  • cd pcbflow
  • git checkout try1
  • python setup.py install

Error message

PS C:\try\pcbflow> python setup.py install
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\test-easy-install-18976.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\Lib\site-packages\  

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.readthedocs.io/en/latest/easy_install.html

Please make the appropriate changes for your system and try again.
1 Like

As I dig deeper into this, I think this may be triggered by something non-portable in how setup.py in pcbflow is written.

Maybe @steve.dower can answer?

I’m pretty sure that dependency_links (used in setup.py) is deprecated and should not be used in newer code, as it doesn’t follow modern packaging standards. So that may be the problem. Also, I believe that install_requires uses easy_install if you’re running setup.py install directly. That again is out of date and may not handle the store distribution properly.

I’d suggest:

  1. You use pip to install the package rather than setup.py install. If installing with pip doesn’t work, then the setup.py is very out of date and you should ask the package maintainer to update it.
  2. Ask the package maintainer to update setup.py anyway to conform to more up to date packaging practices. See packaging.python.org for more details.

Yes, you should use pip to install packages, because it already knows how to install into the default virtual environment that already exists :wink: (it’s actually just an override to install into the user site packages, which is managed by Windows in this case so it won’t collide with others and the “Reset my app” function will clear it out).

I have no idea which option will make setuptools do a per-user install, but that’s the option you need if you want to call setup.py install directly.

There is an option, but I prefer not to mention it since you should not run setup.py install ever IMO.

1 Like

Thanks all. As I understand it , this hasn’t been registered on PyPI yet, The author’s setup instructions in the readme were:

Is there still a way to use pip to install it?

I’ve asked Michael to have a look at this thread.

That should work. You can also replace the . in the last command with the path to the pcbflow directory and run it from anywhere.