Closed vinsworldcom closed 7 months ago
I'm facing an issue that could be related to the one here. I use a portable version of Notepad++ v8.6.4 and PythonScript plugin. Until plugin version 3.0.16 everything is fine. Starting with v3.0.17 I get an error message in plugin's console when starting up Notepad++.
Under <Npp-BasePath>\plugins\config\PythonScript\scripts\startup.py
I have a user startup script that contains the following lines:
from Utils.PreProcessorLexer import PreProcessorLexer
pre_processor_lexer_interface = PreProcessorLexer()
The module I want to import is <Npp-BasePath>\plugins\config\PythonScript\scripts\Utils\PreProcessorLexer.py
. However, the error message mentioned above tells me ModuleNotFoundError: No module named 'Utils'
, thus PreProcessorLexer.py
is not loaded. As already said, this misbehavior started with PythonScript plugin v3.0.17, with v3.0.16 everything works.
Since my knowledge of Python is very limited, I'm not sure if this is related to the issue at hand. Maybe someone more knowledgeable could share their thoughts.
Additional info: <Npp-BasePath>\plugins\config\PythonScript\scripts\Utils
does not contain a file named __init__py
, in case that would be relevant.
@dinkumoil almost certainly the same issue I describe. No fix yet.
@vinsworldcom I have tried this artifact .
Looks like site config changed from enabled to disabled https://github.com/bruderstein/PythonScript/commit/f4b6f0241b68cdf00cc2a00026ba62b9fe7b19ef#diff-9270932fd4a7a300cabd17a1f0462588f5111832df6302c3009a56fdccc5f7eb
Check value in PythonScipt sys.flags.no_site
which v3.0.17 displays 0
and the artifact displays 1
. In C++ source code Py_NoSiteFlag = 1;
and config.site_import = 0;
are not equivalent including the other 2 config lines.
For AppData user paths, you could try to add to start.py as a workaround with the artifact
@dinkumoil No scripts
dir in sys.path
of released v3.0.17 so Utils
not found by import
statement. The artifact might be better else probably go back to v3.0.16 if worked for you.
For AppData user paths, you could try to add to start.py as a workaround with the artifact
YES! I can and it works fine with my win32gui
issue mentioned here.
Currently using:
### START: Deal with 3.0.17 sys.path/site bug: https://github.com/bruderstein/PythonScript/issues/322
import site
site.ENABLE_USER_SITE = True
site.main()
paths = [
'C:\\Users\\VinsWorldcom\\AppData\\Roaming\\Python\\Python312\\site-packages',
'C:\\Users\\VinsWorldcom\\AppData\\Roaming\\Python\\Python312\\site-packages\\win32',
'C:\\Users\\VinsWorldcom\\AppData\\Roaming\\Python\\Python312\\site-packages\\win32\\lib',
'C:\\Users\\VinsWorldcom\\AppData\\Roaming\\Python\\Python312\\site-packages\\Pythonwin',
'C:\\usr\\bin\\npp64\\plugins\\PythonScript\\Lib\\site-packages',
]
for path in paths:
if path not in sys.path:
sys.path.append(path)
### END: Deal with 3.0.17 sys.path/site bug
Cheers.
@vinsworldcom @dinkumoil Could you please test with artifacts from https://ci.appveyor.com/project/bruderstein/pythonscript/builds/49581044 if with the change https://github.com/bruderstein/PythonScript/commit/0fc150ccfc419cba985bb04c1a450e573322a4dd behaviour is working again as with 3.0.16.
@chcg The artifact at https://github.com/bruderstein/PythonScript/commit/0fc150ccfc419cba985bb04c1a450e573322a4dd seems to have fixed it for me! Using my original 'startup.py' without the fix I mentioned above works as previously with 3.0.16.
Thank you!!
@chcg I can confirm that the artifact fixed the issue. Thank you!
Notice :
'C:\usr\bin\npp64\plugins\PythonScript\lib\site-packages
is missing and it was there before (see previous posts).
Also, now it's not finding any of the local system Python paths. Note I do not have the "Prefer installed Python libraries ..." checked, but the previous versions always found the local system Python paths:
'C:\Users\VinsWorldcom\AppData\Roaming\Python\Python3xx\site-packages\**'
This new commit is no longer finding them, and as you can see from above, the "original" 3.0.17 did find the local system Python paths.
At the very least, if it imports the local PythonScript site packages:
plugins\PythonScript\lib\site-packages
Then I can put a .pth file in that directory with the paths of my system Python installation site files and get the functionality I want.
Cheers.
Originally posted by @vinsworldcom in https://github.com/bruderstein/PythonScript/issues/321#issuecomment-1880215781