Skip to content

ModuleNotFoundError: No module named 'encodings' #909

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

Open
ArkadiuszMichalski opened this issue Dec 16, 2020 · 4 comments
Open

ModuleNotFoundError: No module named 'encodings' #909

ArkadiuszMichalski opened this issue Dec 16, 2020 · 4 comments
Labels

Comments

@ArkadiuszMichalski
Copy link

ArkadiuszMichalski commented Dec 16, 2020

Hi, I use Win7 and download Winpython64-3.8.6.0dot.exe. When I run WinPython Command Prompt.exe, pass python and press Enter then get this error:

C:\Users\Arek\Desktop\WPy64-3860\scripts>python
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\python.exe
'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '\u0158E'
  sys.base_prefix = '.'
  sys.base_exec_prefix = '.'
  sys.executable = '\u0158E'
  sys.prefix = '.'
  sys.exec_prefix = '.'
  sys.path = [
    'C:\\Users\\Arek\\Desktop\\WPy64-3860\\python-3.8.6.amd64\\python38.zip',
    '.\\DLLs',
    '.\\lib',
    '',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the file
system encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

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

C:\Users\Arek\Desktop\WPy64-3860\scripts>

I have same problem with oryginal python-3.9.1-embed-amd64 when try running python.exe (from official page).

The important thing is that file winpython\python-3.8.6.amd64\python.exe from your project works fine (don't get any error). Any tips on what's the problem? I need access to pip (for install module) and to run py files in portable way.

@ArkadiuszMichalski
Copy link
Author

Hmm, in env.bat I add set PYTHONPATH=%WINPYDIR%\lib and it works fine. Why this is not set by default in your project? Since it is portable, I shouldn't do anything to just execute some simple python code.

Btw, where are modules located by default if I use WinPython Command Prompt.exe? Where should I install them so that then the import will work?

@ArkadiuszMichalski
Copy link
Author

ArkadiuszMichalski commented Dec 16, 2020

Unfortunately I still have a problem for pip:

C:\Users\Arek\Desktop\WPy64-3860\scripts>pip
Traceback (most recent call last):
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\runpy.py", line
194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\runpy.py", line
87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\Scripts\pip.exe\__m
in__.py", line 4, in <module>
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\site-packages\p
p\_internal\cli\main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\site-packages\p
p\_internal\cli\autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\site-packages\p
p\_internal\cli\main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\site-packages\p
p\_internal\cli\cmdoptions.py", line 23, in <module>
    from pip._internal.cli.progress_bars import BAR_TYPES
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\site-packages\p
p\_internal\cli\progress_bars.py", line 12, in <module>
    from pip._internal.utils.logging import get_indentation
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\site-packages\p
p\_internal\utils\logging.py", line 9, in <module>
    import logging.handlers
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\logging\handler
.py", line 26, in <module>
    import logging, socket, os, pickle, struct, time, re
  File "C:\Users\Arek\Desktop\WPy64-3860\python-3.8.6.amd64\lib\socket.py", lin
 49, in <module>
    import _socket
ModuleNotFoundError: No module named '_socket'

Any tips here? Looks like _socket is missing.

@stonebig
Copy link
Contributor

stonebig commented Dec 19, 2020

Windows 7 is not supported, may not work anymore
Meanwhile, I only find this that may be of help or not pypa/virtualenv#1069

@ArkadiuszMichalski
Copy link
Author

From first post we see this:

  sys.path = [
    'C:\\Users\\Arek\\Desktop\\WPy64-3860\\python-3.8.6.amd64\\python38.zip',
    '.\\DLLs',
    '.\\lib',
    '',
  ]

I don't know why first path is absolute but 2 and 3 is relative, and relative to what? Solution is to manually set this two paths (DLL and lib) in PYTHONPATH variable. After that python.exe and pip works.

There still is some other problem with pip when I try install some package. Files (as cache) are downloaded and put in WinPython\python-3.9.0.amd64 with own subfolder, but after that I get error in console that file can't be installed. It's strange bacause some packages install without any problem:

# works
pip install pyside2
pip install flake8

# not works
pip install pyautogui
pip install pytweening

Can anyone confirm that installing the two abow packages (pyautogui and pytweening) works on the latest versions of WinPython? I wonder if it is the fault of the packages (not compatible with the latest WinPython version) or maybe just incompatibility with the operating system.

The solution is to manually put the files in the right places, but that's an extra step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants