PYTHONPATH ignored when using bundle python (tested in 2.63a Win32) #31506
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#31506
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
%%%The environment variable PYTHONPATH is ignored when Blender finds the bundled python package on startup.
Problem: it prevents to use external module in custom directories.
This problem does NOT happen if the bundle python package is not present (delete 2.63/python directory for this). Of course, an external Python 3.2 install is required to get Blender working in this case; blender finds it and adds PYTHONPATH to the system path as it should.
How to reproduce: install Blender from windows installer, open a command windows, set PYTHONPATH to a value of choice, start blender, display Python console, execute following code: "import sys;print(sys.path)", verify that PYTHONPATH directory is not listed.
%%%
Changed status to: 'Open'
%%%This is for windows only, from the code seems this is why...
ifdef _WIN32
endif
So we can disable this but then if it crashes I'd need some windows developer to be able to look into this.
Could you check if this crashes still?, if not Im happy to remove.%%%
%%%I just tested a CMake/MSVC2008 debug build of the current SVN with the above line removed and I get no crash. As expected the PYTHONPATH appears in sys.path when using the bundled python.
%%%
%%%Apparently it's related to setting the PYTHONPATH to an incompatible version?
http://lists.blender.org/pipermail/bf-blender-cvs/2010-September/031148.html
It would be good to test a release/debug builds together with PYTHONPATH set to a python 2.x or 3.0 installation, and see if that crashes. If not then I guess this can be removed.%%%
%%%Indeed, if PYTHONPATH points to the 'lib' directory of an incompatible python installation, then there is a crash on startup with the message "unable to load the file system codec". This problem also occurs when starting the Python32 interpreter in the same condition. The message is more explicit and shows what's happening:
E:\Python-3.2\PCbuild>set PYTHONPATH=E:\Python-2.6.2\Lib
E:\Python-3.2\PCbuild>python_d.exe
Fatal Python error: Py_Initialize: unable to load the file system codec
So basically, the directory pointed by PYTHONPATH is searched first when importing the 'encoding' module as part of the interpreter initialization, and of course it crashes.
The problem does not occur if PYTHONPATH points to directories that do not contain an 'encoding' module, which I think is the most common case: the user has no reason to put a Python Lib directory in PYTHONPATH since the interpreter automatically adds it.
Since the problem also occurs with the interpreter, I don't think the workaround in Blender is justified. Can it be removed?
%%%
%%%disabled and referenced this report, at least then there is some reference if someone runs into this again.%%%
Changed status from 'Open' to: 'Resolved'
%%%Hola :)
Thought I would add this report to this one, to keep from repetitive post.
This is reported from samiboy on graphicall
"I have been having a problem with running new builds after, say, 46384. That was the last build that didn't throw the following error:
found bundled python: c:\users\samschad\downloads\7150_win.x647.x64-46969\win7.x64-46969\2.3\python
Fatal Python error: Py_initialize: unable to load the file system codec
File "C:\Python26\Lib\encodings_init_.py", line 123
raise CodecRegistryError,\
SyntaxError: invalid syntax
I'm running win7x64 pro on a core i7 920 with 12 gigs of ram and dual GTX 470s.
any suggestions?"
I build trunk with MSVC2008 Pro + CMAKE on Win7.x64
Cheers,
~Tung%%%
%%%I have exactly the same problem. It's related to any build of Blender from Graphicall or blender.org's Builder. It doesn't happen in official 2.63.
I'm using Windows 7 64 bit. PYTHONPATH (computer Properties > Advanced) is set to Python 2.6, as I frequently use Blender 2.49.
Even though Blender finds bundled python - it doesn't matter if I point to it through --env-system-python argument or not - Blender still tries to use Python 2.6 from PYTHONPATH.
It causes an error on startup:
found bundled python: C:\Users\Oskar\Desktop\blender-2.63-r50530-win64\2.63\python
Fatal Python error: Py_Initialize: unable to load the file system codec
SyntaxError: invalid syntax%%%