Skip to content
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

ImportError: Interpreter change detected - this module can only be loaded into one interpreter per process. #39

Closed
Bird23 opened this issue Aug 30, 2024 · 11 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Bird23
Copy link

Bird23 commented Aug 30, 2024

No description provided.

@Bird23
Copy link
Author

Bird23 commented Aug 30, 2024

I like to use this in Siemens NX during Manufacturing Machine Simulation because I wrote my own Python files. If I run a journal then I can setup the script with Global Interpreter Lock and the encrypted script works perfectly a couple of times after eachother.
If I do simulation I cannot force GIL so the first time the encrypted scipts get decrypted by the loader. The second time I get "ImportError: Interpreter change detected - this module can only be loaded into one interpreter per process." and the encrypted scipt does not get decrypted because the loader is not loaded again. Whatever I do, I cannot get it to work a second time.

@ZhaoQi99
Copy link
Owner

Hi! The loader doesn't need to be loaded again. It simply inserte EncryptFileFinder to sys.meta_path once.
Can you provide more information, such as a small demo?

sys.meta_path.insert(0, EncryptFileFinder())

@Bird23
Copy link
Author

Bird23 commented Aug 31, 2024 via email

@ZhaoQi99
Copy link
Owner

ZhaoQi99 commented Sep 2, 2024

I didn't find any logs related to ImportError in the traceback you provided.

@Bird23
Copy link
Author

Bird23 commented Sep 2, 2024 via email

@ZhaoQi99
Copy link
Owner

ZhaoQi99 commented Sep 2, 2024

Can you provide a small demo and tell me how you call python the second time?

@Bird23
Copy link
Author

Bird23 commented Sep 2, 2024 via email

@Bird23
Copy link
Author

Bird23 commented Sep 25, 2024 via email

@ZhaoQi99 ZhaoQi99 added help wanted Extra attention is needed good first issue Good for newcomers labels Sep 25, 2024
@Bird23 Bird23 closed this as completed Sep 25, 2024
@Bird23 Bird23 reopened this Sep 25, 2024
@Bird23
Copy link
Author

Bird23 commented Sep 25, 2024

The problem was that windows was keeping the loader in-use. Due to a few simple lines of code, the loader's file-handle is released, so the loader can start again.

@Bird23 Bird23 closed this as completed Sep 25, 2024
@Bird23
Copy link
Author

Bird23 commented Oct 1, 2024 via email

@ZhaoQi99
Copy link
Owner

ZhaoQi99 commented Oct 8, 2024

Hi, One final question. Since I can use pyencrypt now, when do you think that you have added the loader name option to pyencrypt? Best regards, Jacco Op wo 25 sep 2024 om 10:14 schreef Jacco Loonstra @.***

: Hi, Good news. Your pyencrypt is working now. The problem was that the loader was kept open(in use) by windows the first time and was not loaded (executed) again. The solution is, with a little bit of python code, closing the file-handle of the loader. Now it gets loaded again. Thanks for your very nice pyencrypt module. Best regards, Jacco Op vr 30 aug 2024 om 18:12 schreef Qi Zhao @.>: > Hi! The loader doesn't need to be loaded again. It simply inserte > EncryptFileFinder to sys.meta_path once. > Can you provide more information, such as a small demo? > > >

sys.meta_path.insert(0, EncryptFileFinder())
> > — > Reply to this email directly, view it on GitHub > <#39 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AEGHFLBGOGIABM2CMN7TLF3ZUCKYRAVCNFSM6AAAAABNMVONH2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRRHAYTMMRYGQ > . > You are receiving this because you authored the thread.Message ID: > @.> >

Sorry, I'm a bit busy recently. I'll let you know when it's added. #40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants