On Tue, Feb 21, 2017 at 1:25 AM, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: > (2) Add each category to the PYTHONPATH. One easy way to do so is by adding > the directories to a .pth file.
PYTHONPATH isn't a synonym for sys.path. The PYTHONPATH environment variable gets used by every installed interpreter, which can be a problem if it's set permanently. Using .pth files, as suggested here, is one way around this. In general, virtual environments [1] are convenient for development. Install what you need for a project from PyPI, a local wheel cache, or directly from VCS. IDEs such as PyCharm have integrated support for virtual environments. Entry-point scripts in a virtual environment should have a shebang that executes the environment's interpreter, so they can be run even when the environment isn't active. [1]: https://docs.python.org/3/library/venv.html The rest of this message is just for Windows. To support shebangs, make sure that .py[w] files are associated with the py launcher, which is installed with Python 3. The installer defaults to associating .py[w] files with the Python.File and Python.NoConFile program identifiers (ProgIds). Change it back if you've modified it. Don't use the command prompt's assoc command for this. Use the control panel "Default Programs -> Set Associations" dialog (i.e. associate a file type or protocol with a program). The descriptions for .py and .pyw in this dialog should be "Python File" and "Python File (no console)". When you double click on the entries for .py and .pyw, the associated program should be "Python" with a rocket on the icon. If not, and you see it in the list, select it. Otherwise ensure that the Python.File and Python.NoConFile ProgIds are configured to use the py.exe and pyw.exe launchers. If the launcher was installed for all users (i.e. per machine), you can use ftype in an *elevated* command prompt to query and set Python.[NoCon]File. For example: C:\>ftype Python.File Python.File="C:\Windows\py.exe" "%1" %* C:\>ftype Python.NoConFile Python.NoConFile="C:\Windows\pyw.exe" "%1" %* If the launcher was installed for the current user only (i.e. per user), then you cannot use the ftype command since it only accesses the local-machine settings. Also, even if you've installed for all users, maybe you have an old value in HKCU, which takes precedence over HKLM when the system reads the merged HKCR view. Use regedit to manually edit the per-user keys if they exist. If "HKCU\Software\Classes\Python.File\shell\open\command" exists, its default value should be a template command to run the fully-qualified path to py.exe plus "%1" for the target script and %* for the command-line arguments, as shown above. Similarly, if "HKCU\Software\Classes\Python.NoConFile\shell\open\command" exists, it should run the same command but with pyw.exe substituted for py.exe. -- https://mail.python.org/mailman/listinfo/python-list