Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a fairly good answer but on windows, there’s no python3, so that’s your first command being broken.


Right, on Windows the recipe needs a few alterations but is essentially the same. This should work:

  > py -3 -m venv --upgrade-deps my-virtual-environment
  > my-virtual-environment\Scripts\pip install whatever-third-party-package
  > my-virtual-environment\Scripts\python my-script.py
This assumes that the Python launcher (py.exe) was installed when installing Python, which it is by default.


Py is not installed when you get it from windows store. Another gotcha to worry about.

The story about python on windows is a nightmare for new people for these reasons. And installing packages - while not as bad anymore - is a mixed bag due to fewer precompiled C extensions than on linux.

Paradoxically, microsoft have spent some effort on improving things. This has led to multiple incompatible choices which, effectively, has made the experience worse.


Sure. Add "Get the actual official Python from python.org, not whatever mess Microsoft has cooked up" as step 0.

If you do use Microsoft's Python distribution though, are you saying that it provides neither "python3" nor "py"? How do you use it then?

According to the docs[0] the Microsoft Store package should provide "python" and "python3" commands (effectively unsolving the problem solved by the Python launcher, I guess?) so either my original suggestion of "python3" or my subsequent suggestion of "py -3" should work, depending on which distribution was installed.

[0] https://docs.python.org/3.11/using/windows.html#the-microsof...


See this is the problem. You're already several "ah yes and you need to"s deep.


Not really. It's the same 3-step process in both cases.


You literally gave a different process on Windows to Linux.


It's the same process described with different syntax for different operating systems. It contains no "ah yes and you need to" and is not "deep". Here's a templated version of the same process, if you prefer, which works on both Windows and Linux:

1. [PATH TO YOUR PYTHON COMMAND IN WHATEVER PYTHON DISTRIBUTION YOU YOURSELF INSTALLED ON YOUR OS OF CHOICE] -m venv --upgrade-deps my-virtual-environment

2. [PATH TO PIP COMMAND INSIDE THE DIRECTORY CREATED BY THE FIRST COMMAND IN THE SYNTAX OF YOUR OS OF CHOICE] install whatever-third-party-package

3. [PATH TO PYTHON COMMAND INSIDE THE DIRECTORY CREATED BY THE FIRST COMMAND IN THE SYNTAX OF YOUR OS OF CHOICE] my-script.py


The fact that some parts of the command are the same doesn't excuse the other parts being pointlessly different. It's a paper cut for beginners. One of hundreds, which makes the whole Python UX completely awful.


Which languages do this much better? Honest question.


Rust, Go, Javascript/Typescript, Java, C#, Dart, ... I mean it's basically all of them except C/C++. And OCaml. OCaml is the worst.

Rust, Go and Deno are definitely part of a new breed of "developer tooling should just bloody work!" languages. Python is from the era of "eh, you figure it out" mixed with a little of "I'm making this up as I go along".


True, the last three build tooling as a part of the language from the start.

Java? I seem to recall build systems and tooling being more pain than Fortran. Not sure I believe that one. Certainly not my experience.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: