Skip to content

Can't run modules after installing with CLI #92219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
github-account1111 opened this issue May 3, 2022 · 5 comments
Closed

Can't run modules after installing with CLI #92219

github-account1111 opened this issue May 3, 2022 · 5 comments
Labels
OS-windows type-bug An unexpected behavior, bug, or error

Comments

@github-account1111
Copy link

github-account1111 commented May 3, 2022

Bug report

I am only able to run the installed modules after installing Python with the GUI:

20220504-compress.mp4

Installing with the CLI using equivalent flags leads to errors when trying to install or run the modules:

> .\python-3.10.4-amd64.exe /passive `
>> InstallAllUsers=1 `
>> AssociateFiles=0 `
>> PrependPath=1 `
>> Include_doc=0 `
>> Include_dev=0 `
>> Include_lib=0 `
>> Include_tcltk=0 `
>> Include_test=0 `
>> Include_tools=0
PS C:\Users\user\Downloads> py -m pip install gallery-dl
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'C:\Program Files\Python310\python.exe'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'C:\\Program Files\\Python310\\python.exe'
  sys.base_prefix = ''
  sys.base_exec_prefix = ''
  sys.platlibdir = 'lib'
  sys.executable = 'C:\\Program Files\\Python310\\python.exe'
  sys.prefix = ''
  sys.exec_prefix = ''
  sys.path = [
    'C:\\Program Files\\Python310\\python310.zip',
    '.\\DLLs',
    '.\\lib',
    'C:\\Program Files\\Python310',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000bfc (most recent call first):
  <no Python frame>

No matter what combination of flags, there is some error:

> .\python-3.10.4-amd64.exe /passive `
>> InstallAllUsers=1 `
>> AssociateFiles=0 `
>> PrependPath=1 `
>> Include_doc=0 `
>> Include_dev=0 `
>> Include_tcltk=0 `
>> Include_test=0 `
>> Include_tools=0
PS C:\Users\user\Downloads> py -m pip install gallery-dl
Collecting gallery-dl
  Downloading gallery_dl-1.21.2-py3-none-any.whl (495 kB)
     ---------------------------------------- 495.2/495.2 KB 10.3 MB/s eta 0:00:00
Collecting requests>=2.11.0
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
     ---------------------------------------- 63.1/63.1 KB 3.3 MB/s eta 0:00:00
Collecting charset-normalizer~=2.0.0
  Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
     ---------------------------------------- 149.2/149.2 KB ? eta 0:00:00
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     ---------------------------------------- 61.2/61.2 KB ? eta 0:00:00
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.9-py2.py3-none-any.whl (138 kB)
     ---------------------------------------- 139.0/139.0 KB 8.6 MB/s eta 0:00:00
Installing collected packages: certifi, urllib3, idna, charset-normalizer, requests, gallery-dl
  WARNING: The script normalizer.exe is installed in 'C:\Program Files\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script gallery-dl.exe is installed in 'C:\Program Files\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed certifi-2021.10.8 charset-normalizer-2.0.12 gallery-dl-1.21.2 idna-3.3 requests-2.27.1 urllib3-1.26.9
PS C:\Users\user\Downloads> gallery-dl
gallery-dl : The term 'gallery-dl' 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.
At line:1 char:1
+ gallery-dl
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (gallery-dl:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\user\Downloads> py -m gallery-dl
C:\Program Files\Python310\python.exe: No module named gallery-dl

Even if I literally put a =1 for every flag I get a no module error.

Your environment

  • CPython versions tested on: 3.10.4
  • Operating system and architecture: Windows 11 64-bit
@github-account1111 github-account1111 added the type-bug An unexpected behavior, bug, or error label May 3, 2022
@github-account1111
Copy link
Author

github-account1111 commented May 5, 2022

I've narrowed it down to the "Install for all users" option in Advanced Options.
If that is selected, I cannot run modules.
I have tried multiple times on a clean install through a Hyper-V VM.

@zooba
Copy link
Member

zooba commented Jul 29, 2022

You need to restart the shell between installing and trying to use the new PATH entries. Nothing in any terminal will automatically pick up global environment changes - they don't even listen for them, and it would cause havoc if they tried.

py -m can only run importable Python modules, which don't allow hyphens. So py -m gallery-dl is never going to work, and you probably need a different name (possibly gallery_dl, but I didn't look it up).

Choosing include_lib=0 (and many of those other options) will definitely lead to a broken install. That's why there's no UI (and should be no documentation) for them.

Based on the report, I suspect that not restarting the shell after the installer updates PATH is the root cause. If it's not, feel free to reopen the issue.

@zooba zooba closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2022
@github-account1111
Copy link
Author

github-account1111 commented Jul 30, 2022

I have tried restarting not only the shell, but also the computer, all to no avail.

Nothing in any terminal will automatically pick up global environment changes - they don't even listen for them, and it would cause havoc if they tried.

Not sure if this is true.
Most other software picks up just fine in the same shell session right after installation, including Python when not installed for all users.

py -m can only run importable Python modules, which don't allow hyphens. So py -m gallery-dl is never going to work, and you probably need a different name (possibly gallery_dl, but I didn't look it up).

Again, py -m gallery-dl works just fine if the "Install for all users" option is not selected.

Choosing include_lib=0 (and many of those other options) will definitely lead to a broken install. That's why there's no UI (and should be no documentation) for them.

There's documentation for it.
There's also no distinction between what leads to borked installs, and what doesn't.
I just went with the flags I deemed appropriate for my use case.
Could you expand on which other options?

I don't see the option to reopen.

@zooba
Copy link
Member

zooba commented Aug 1, 2022

Not sure if this is true.
Most other software picks up just fine in the same shell session right after installation, including Python when not installed for all users.

This will only happen if they install into directories already on your PATH. This is not what Python does (other than the Store package), so it won't show up until you restart the shell. About the only way this could happen is if you (1) have a messed up PATH (which is likely if you've installed Python before - MSI doesn't handle the updates well), or (2) if you uninstalled Python in the same session and are reinstalling it.

Again, py -m gallery-dl works just fine

I stand corrected. The -m option can run non-importable modules.

There's documentation for it.

News to me. I guess someone decided they should all be documented, not just the ones that are usually useful. I'd be open to a PR to remove the ones that don't have any UI (though chances are I approved adding them because someone convinced me that nobody would ever do what you've done and wonder why everything breaks... since clearly someone might, we should remove them from the docs).

@zooba
Copy link
Member

zooba commented Aug 1, 2022

I don't see the option to reopen.

You haven't proven a bug yet, so there's still nothing for us to fix. If a ton of other people start coming in saying they're seeing the same thing, we can take a look, but for the most part when only one person is having trouble it's because of their own machine.

Can you run both types of install and attach the log files for each? They'll be in your %TEMP% directory, and there'll be a big set of each. We're mainly interested in the path ones, since that seems to be where you're hitting trouble.

zooba added a commit to zooba/cpython that referenced this issue Aug 1, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 1, 2022
…the install (pythonGH-95548)

(cherry picked from commit d2c1a9c)

Co-authored-by: Steve Dower <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 1, 2022
…the install (pythonGH-95548)

(cherry picked from commit d2c1a9c)

Co-authored-by: Steve Dower <[email protected]>
miss-islington added a commit that referenced this issue Aug 2, 2022
…stall (GH-95548)

(cherry picked from commit d2c1a9c)

Co-authored-by: Steve Dower <[email protected]>
erlend-aasland pushed a commit that referenced this issue Aug 2, 2022
…stall (GH-95548) (#95550)

(cherry picked from commit d2c1a9c)

Co-authored-by: Steve Dower <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-windows type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants