Newly installed Blender won't open in windows 10 due to python error #98131

Closed
opened 2022-05-15 04:23:51 +02:00 by Joshua Dempster · 15 comments

System Information
Operating system: Windows 10
Graphics card: GTX 970

Blender Version
Broken: 3.1.2

Short description of error
I have my own copy of Python installed (3.7). I downloaded and installed the official package from blender.org. Blender opens a window then closes. Opening with Powershell gets the following traceback:


Internal error initializing Python!
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):

File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\site.py", line 73, in <module>
  __boot()
File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\site.py", line 26, in __boot
  import imp  # Avoid import loop in Python >= 3.3
File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\imp.py", line 19, in <module>
  from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name
File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 51, in <module>
  _w_long = _bootstrap_external._w_long

AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long'


This installation of python is the only one in my path and pythonpath variables. I experimented with forcing it to load ._bootstrap_external fresh from source, rather than the frozen version. This got me past this exception, but led to a new traceback that makes me think the underlying issue is a conflict between Blender's and my system's pythons:


Internal error initializing Python!
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):

File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\site.py", line 73, in <module>
  __boot()
File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\site.py", line 34, in __boot
  imp.load_module('site', stream, path, descr)
File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\imp.py", line 235, in load_module
  return load_source(name, filename, file)
File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\imp.py", line 170, in load_source
  module = _exec(spec, sys.modules[name])
File "<frozen importlib._bootstrap>", line 619, in _exec
File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\importlib\_bootstrap_external.py", line 728, in exec_module
  _bootstrap._call_with_frames_removed(exec, code, module.__dict__)
File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 617, in <module>
  main()
File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 604, in main
  known_paths = addsitepackages(known_paths)
File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 387, in addsitepackages
  addsitedir(sitedir, known_paths)
File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 226, in addsitedir
  addpackage(sitedir, name, known_paths)
File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 175, in addpackage
  f = io.TextIOWrapper(io.open_code(fullname), encoding="locale")

AttributeError: module 'io' has no attribute 'open_code'


Exact steps for others to reproduce the error
Download blender onto a windows machine with a local installation of Python 3.7.

**System Information** Operating system: Windows 10 Graphics card: GTX 970 **Blender Version** Broken: 3.1.2 **Short description of error** I have my own copy of Python installed (3.7). I downloaded and installed the official package from blender.org. Blender opens a window then closes. Opening with Powershell gets the following traceback: __________________________________________________________ Internal error initializing Python! Fatal Python error: init_import_site: Failed to import the site module Python runtime state: initialized Traceback (most recent call last): ``` File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\site.py", line 73, in <module> __boot() File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\site.py", line 26, in __boot import imp # Avoid import loop in Python >= 3.3 File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\imp.py", line 19, in <module> from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 51, in <module> _w_long = _bootstrap_external._w_long ``` AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long' ______________________________________________________________________ This installation of python is the only one in my path and pythonpath variables. I experimented with forcing it to load ._bootstrap_external fresh from source, rather than the frozen version. This got me past this exception, but led to a new traceback that makes me think the underlying issue is a conflict between Blender's and my system's pythons: ______________________________________________________ Internal error initializing Python! Fatal Python error: init_import_site: Failed to import the site module Python runtime state: initialized Traceback (most recent call last): ``` File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\site.py", line 73, in <module> __boot() File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\site.py", line 34, in __boot imp.load_module('site', stream, path, descr) File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\imp.py", line 235, in load_module return load_source(name, filename, file) File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\imp.py", line 170, in load_source module = _exec(spec, sys.modules[name]) File "<frozen importlib._bootstrap>", line 619, in _exec File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\importlib\_bootstrap_external.py", line 728, in exec_module _bootstrap._call_with_frames_removed(exec, code, module.__dict__) File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 617, in <module> main() File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 604, in main known_paths = addsitepackages(known_paths) File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 387, in addsitepackages addsitedir(sitedir, known_paths) File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 226, in addsitedir addpackage(sitedir, name, known_paths) File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\site.py", line 175, in addpackage f = io.TextIOWrapper(io.open_code(fullname), encoding="locale") ``` AttributeError: module 'io' has no attribute 'open_code' ________________________________________________________________________________ **Exact steps for others to reproduce the error** Download blender onto a windows machine with a local installation of Python 3.7.

Added subscriber: @joshdempster

Added subscriber: @joshdempster

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

Thanks for the report.

Could you confirm where you downloaded the Blender installer from?

Blender installer from https://www.blender.org/download/ already comes with a bundled python 3.10 (3.7 is not supported)

If you are not using the python 3.10 package in blender, it is to be expected that it will not work.

Thanks for the report. Could you confirm where you downloaded the Blender installer from? Blender installer from https://www.blender.org/download/ already comes with a bundled python 3.10 (3.7 is not supported) If you are not using the python 3.10 package in blender, it is to be expected that it will not work.

Yes, I downloaded it from blender.org/download. The problem is that Blender is using my system python, not the bundled python. Specifically, I suspect Blender is invoking the system python interpreter, then trying to use it to read in packages from the Blender bundled version, or vice versa.

Is it possible that Blender launches with a command like

  >>python <some_file.py>

instead of

  >>\absolute\path\blender\python <some_file.py>

? Just a guess.

Yes, I downloaded it from blender.org/download. The problem is that Blender is using my system python, not the bundled python. Specifically, I suspect Blender is invoking the system python interpreter, then trying to use it to read in packages from the Blender bundled version, or vice versa. Is it possible that Blender launches with a command like ``` >>python <some_file.py> ``` instead of ``` >>\absolute\path\blender\python <some_file.py> ``` ? Just a guess.
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Member

when you start bender using the blender_factory_startup.cmd batch file located next to blender.exe is it happier?

when you start bender using the `blender_factory_startup.cmd` batch file located next to blender.exe is it happier?

Yup, that launches successfully. I attached the system info.blender_system_info.txt

Yup, that launches successfully. I attached the system info.[blender_system_info.txt](https://archive.blender.org/developer/F13083059/blender_system_info.txt)
Member

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Member

blender_factory_startup.cmd clears the PYTHONPATH env variable before starting blender that's likely why it's starting, afaik blender is setup by default to ignore it unless you pass a very specific switch telling it not to, so i'm not entirely sure what's going on here, @ideasman42 any bright ideas?

blender_factory_startup.cmd clears the `PYTHONPATH` env variable before starting blender that's likely why it's starting, afaik blender is setup by default to ignore it unless you pass a very specific switch telling it not to, so i'm not entirely sure what's going on here, @ideasman42 any bright ideas?

Using PYTHONPATH should be an exceptional case, if the PYTHONPATH is used anyway, PyPreConfig_InitIsolatedConfig may not be working as it should.

Committed a change that logs when PYTHONPATH expected to be used.

With ebb492a389 or newer (will be in the next daily build) please try run this from the terminal:

blender --log "bpy.interface.*" --log-level 2

As well as:

blender --log "bpy.interface.*" --log-level 2 --python-use-system-env

The first command should ignore the PYTHONPATH and succeed in starting Blender.

The second may fail if PYTHONPATH points to an unsupported Python version.


Both commands should show a message:

INFO (bpy.interface): source/blender/python/intern/bpy_interface.c:316 BPY_python_start: Initializing *without* support for the systems Python environment such as 'PYTHONPATH' and the user-site directory.

... where *with* / *without* depend on passing in the --python-use-system-env argument.


Please try an updated build and show the full output of both commands.

Using `PYTHONPATH` should be an exceptional case, if the PYTHONPATH is used anyway, `PyPreConfig_InitIsolatedConfig` may not be working as it should. Committed a change that logs when `PYTHONPATH` expected to be used. With ebb492a389 or newer (will be in the next daily build) please try run this from the terminal: `blender --log "bpy.interface.*" --log-level 2` As well as: `blender --log "bpy.interface.*" --log-level 2 --python-use-system-env` The first command should ignore the PYTHONPATH and succeed in starting Blender. The second may fail if PYTHONPATH points to an unsupported Python version. ---- Both commands should show a message: ``` INFO (bpy.interface): source/blender/python/intern/bpy_interface.c:316 BPY_python_start: Initializing *without* support for the systems Python environment such as 'PYTHONPATH' and the user-site directory. ``` ... where `*with*` / `*without*` depend on passing in the `--python-use-system-env` argument. ---- Please try an updated build and show the full output of both commands.
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Please try an updated build and show the full output of both commands.

@joshdempster ^

> Please try an updated build and show the full output of both commands. @joshdempster ^
Member

Changed status from 'Needs User Info' to: 'Archived'

Changed status from 'Needs User Info' to: 'Archived'
Member

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed.

Thanks again for the report. If the problem persists please open a new report with the required information.

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed. Thanks again for the report. If the problem persists please open a new report with the required information.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#98131
No description provided.