Falldog / pyconcrete

Protect your python script, encrypt it as .pye and decrypt when import it
Apache License 2.0
702 stars 150 forks source link

Python version doesn't match with magic: python(62211) != pye(47360) #35

Closed vonzhou closed 6 years ago

vonzhou commented 6 years ago

Traceback (most recent call last): File "xxxx/2.2.6/src/main.py", line 5, in from XxxxManager import * File "/usr/local/lib/python2.7/dist-packages/pyconcrete/init.py", line 63, in load_module self._validate_version(data) File "/usr/local/lib/python2.7/dist-packages/pyconcrete/init.py", line 95, in _validate_version raise ValueError("Python version doesn't match with magic: python(%d) != pye(%d)" % (py_magic, pye_magic)) ValueError: Python version doesn't match with magic: python(62211) != pye(47360)

Falldog commented 6 years ago

Please make sure the Python version for compiled .pye & execution .pye should be the same

dd404x commented 1 year ago

You can check the code, guys. I had this error today and found out that some of the code had #!/bin/env python set, while I compiled it using Python 3. Removing the env portion from that code fixed the issue.

Akashram08 commented 9 months ago

raise ValueError("Python version doesn't match with magic: python(%d) != pye(%d)" % (py_magic, pye_magic)) I am getting the same error while running the gunicorn after encryting with pyconcrete. I am using python 3.10.12 is that an issue or what. when try to consider the possibility of the version mismatch between the files compiled .pye & execution .pye something is not coming together cause i am activating a virtual env before encryption and packages download. So I don't think there is a possibility where the versions mismatch between those two files.

Falldog commented 9 months ago

@Akashram08 thanks for sharing, I think the complicate environment will encounter some problem, especially under the venv. Can you provide more environment information on it? And then I am able to reproduce it on my local side.

Thank you

Akashram08 commented 9 months ago

@Falldog I think the problem with it might be the compatibility of this package to the python version that I use (which is python 3.10.12). Can you mention the versions of python 3.10 that is supported by this package, I think may be downgrading the version in my machine to that particular version may solve this issue.

Falldog commented 9 months ago

I have just tested on my local machine for python 3.10.12, and the testing result is passed. So I think the problem should be caused by environment. Can you provide the system and virtual environment infomation? It will be better, if you can provide the detail steps to build on a new environment to reproduce the issue.

Akashram08 commented 9 months ago

It is a Linux virtual machine, which has python version 3.10.12 . As far as virtual environment goes we tried to encrypt using pyconcrete after its installation then run it through the gunicorn but I am getting this error "Python version doesn't match with magic: python(62211) != pye(47360)". I have imported pyconcrete in the wsgi.py in my django project file after encryption, also added the .env for running the server. I also made sure I have created and activated a virtual env before encryption installed the package requirements of the project. Is this error occuring because I am having the virtual env activated during the encryption process?

Akashram08 commented 9 months ago

As far as the environment goes it is just created with "python -m venv venv" and activated with the command "source venv/bin/activate"

Akashram08 commented 9 months ago

do you want the list of all packages we install in the venv?

Falldog commented 9 months ago

As far as virtual environment goes we tried to encrypt using pyconcrete after its installation then run it through the gunicorn but I am getting this error "Python version doesn't match with magic: python(62211) != pye(47360)".

I think the issue point will come from gunicorn. Do you install gunicorn by pip or Linux package manager? If you install by Linux package manager, e.g. apt-get, you should make sure the version is the same with your python virtual environment which building your pyconcrete.

Akashram08 commented 9 months ago

@Falldog ok I'll give it a try, I think it might work thanks