Kranos
03/13/2023, 10:16 PMnpm run start
) I get this error:
backend/venv/lib/python3.11/site-packages/supertokens_python/utils.py:197: RuntimeWarning: Inconsistent mode detected, check if you are using the right asgi / wsgi mode
warnings.warn(
INFO: Started server process [57048]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:3001 (Press CTRL+C to quit)
The app runs fine, but now I'm wanting to do some more development on the backend, I'm having issues as I can't access Uvicorn. For example, when I try and visit the server at http://0.0.0.0:3001 I get an internal server error and it throws up a load of other errors:
INFO: 127.0.0.1:58983 - "GET / HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
I've been reading up about the errors and could be to do with me running this on an M1 Mac, so I've tried running Terminal in Rosetta and reinstalling everything, but it's still throwing up these errors. The full list of errors is shown in the screenshot below.
Have you got any experience of these errors and what I can do to fix it?
Thanksrp_st
03/14/2023, 5:12 AMKShivendu
03/14/2023, 6:11 AMKShivendu
03/14/2023, 6:11 AMKranos
03/14/2023, 11:00 AMKranos
03/14/2023, 11:01 AMKranos
03/14/2023, 11:02 AMpip install virtualenv && virtualenv venv && chmod +x venv/bin/activate && . venv/bin/activate && pip install -r requirements.txt && python app.py
Kranos
03/14/2023, 11:04 AMKranos
03/14/2023, 11:06 AMhttp://0.0.0.0:3001
as expected. However when you try to access it, it will throw an Internal Server Error
and produce the following in the Terminal:Kranos
03/14/2023, 11:08 AMKranos
03/14/2023, 11:09 AM@app.get("/sessioninfo")
async def secure_api(s: SessionContainer = Depends(verify_session())):
return {
"sessionHandle": s.get_handle(),
"userId": s.get_user_id(),
"accessTokenPayload": s.get_access_token_payload(),
}
app = CORSMiddleware(
app=app,
allow_origins=[config.app_info.website_domain],
allow_credentials=True,
allow_methods=["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],
allow_headers=["Content-Type"] + get_all_cors_headers(),
)
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=3001)
Kranos
03/14/2023, 11:09 AMfrom supertokens_python.recipe import session, thirdpartyemailpassword, dashboard, emailverification, usermetadata
from supertokens_python.recipe.thirdpartyemailpassword import (
Apple,
Github,
Google,
)
from supertokens_python import (
InputAppInfo,
SupertokensConfig,
)
# this is the location of the SuperTokens core.
supertokens_config = SupertokensConfig(
# https://try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.
connection_uri="https://dev-32918f51bebd11eda5a2f94364e3b284-eu-west-1.aws.supertokens.io:3569",
api_key="MY_API_KEY_HERE"
)
app_info = InputAppInfo(
app_name="panda.ai",
api_domain="http://localhost:3001",
website_domain="http://localhost:3000",
)
framework = "fastapi"
# recipeList contains all the modules that you want to
# use from SuperTokens. See the full list here: https://supertokens.com/docs/guides
recipe_list = [
session.init(), # initializes session features
thirdpartyemailpassword.init(
providers=[
# We have provided you with development keys which you can use for testing.
# IMPORTANT: Please replace them with your own OAuth keys for production use.
Google(
is_default=True,
client_id="1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com",
client_secret="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"
),
# Facebook(
# client_id='FACEBOOK_CLIENT_ID',
# client_secret='FACEBOOK_CLIENT_SECRET'
# ),
Github(
is_default=True,
client_id="467101b197249757c71f",
client_secret="e97051221f4b6426e8fe8d51486396703012f5bd",
),
Apple(
is_default=True,
client_id="4398792-io.supertokens.example.service",
client_key_id="7M48Y4RYDL",
client_team_id="YWQCXGJRJL",
client_private_key="-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----",
),
]
),
usermetadata.init(),
emailverification.init(mode='REQUIRED'),
dashboard.init(api_key="MY_API_KEY_HERE")
]
Kranos
03/14/2023, 3:51 PMhttp://localhost:3001
without creating an Internal Server Error
so I'm not sure how my app is calling /sessioninfo
correctly and not crashingrp_st
03/14/2023, 3:54 PMKranos
03/14/2023, 3:54 PMKShivendu
03/14/2023, 5:54 PMasyncio
of python3.11. I noticed that some other OSS projects have also reported this issue https://github.com/home-assistant/core/issues/88990
The simplest solution is to simply downgrade to python 3.10 which is more stable. If you're using Debian based os, you can do:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.10
I hope it helps. Let me know if you need help with anything else πKranos
03/14/2023, 5:54 PMKranos
03/14/2023, 10:47 PMKranos
03/14/2023, 10:47 PMTraceback (most recent call last):
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/app.py", line 8, in <module>
from supertokens_python.recipe.session import SessionContainer
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/supertokens_python/recipe/session/__init__.py", line 27, in <module>
from .recipe import SessionRecipe
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/supertokens_python/recipe/session/recipe.py", line 58, in <module>
from .recipe_implementation import (
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/supertokens_python/recipe/session/recipe_implementation.py", line 32, in <module>
from . import session_functions
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/supertokens_python/recipe/session/session_functions.py", line 21, in <module>
from .access_token import get_info_from_access_token
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/supertokens_python/recipe/session/access_token.py", line 22, in <module>
from .jwt import ParsedJWTInfo, verify_jwt
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/supertokens_python/recipe/session/jwt.py", line 20, in <module>
from Crypto.Hash import SHA256
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Hash/SHA256.py", line 29, in <module>
_raw_sha256_lib = load_pycryptodome_raw_lib("Crypto.Hash._SHA256",
File "/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/_raw_api.py", line 309, in load_pycryptodome_raw_lib
raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))
OSError: Cannot load native module 'Crypto.Hash._SHA256': Not found '_SHA256.cpython-310-darwin.so', Cannot load '_SHA256.abi3.so': cannot load library '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so': dlopen(/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so, 0x0002): tried: '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (no such file), '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (no such file), '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')). Additionally, ctypes.util.find_library() did not manage to locate a library called '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so', Not found '_SHA256.so'
ERROR: "start:backend" exited with 1.
KShivendu
03/15/2023, 1:18 PMcryptography
and pycryptodome
library. You can look into them to find what exactly works for you.KShivendu
03/15/2023, 1:21 PMpip install cryptography pycryptodome --no-cache-dir --verbose --force-reinstall
seems to have worked for many people.KShivendu
03/15/2023, 1:22 PMKShivendu
03/15/2023, 1:23 PMKranos
03/15/2023, 1:40 PMKranos
03/15/2023, 1:41 PMKranos
03/15/2023, 1:42 PMKranos
03/15/2023, 2:13 PMcryptography==36.0.2
pycryptodome==3.10.4
And I'm still getting a crash and the same errors:
OSError: Cannot load native module 'Crypto.Hash._SHA256': Not found '_SHA256.cpython-310-darwin.so', Cannot load '_SHA256.abi3.so': cannot load library '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so': dlopen(/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so, 0x0002): tried: '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
'/System/Volumes/Preboot/Cryptexes/OS/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (no such file), '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
'/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (no such file), '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')).
Additionally, ctypes.util.find_library() did not manage to locate a library called '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so', Not found '_SHA256.so'
ERROR: "start:backend" exited with 1.
rp_st
03/15/2023, 2:16 PMKranos
03/15/2023, 3:08 PMKranos
03/15/2023, 3:08 PMKranos
03/15/2023, 3:09 PMrp_st
03/15/2023, 3:09 PMrp_st
03/15/2023, 3:09 PMrp_st
03/15/2023, 3:10 PMrp_st
03/15/2023, 3:10 PMKranos
03/15/2023, 3:11 PMrp_st
03/15/2023, 3:22 PMKranos
03/15/2023, 4:17 PMImportError: dlopen(/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.11/site-packages/pydantic/__init__.cpython-311-darwin.so, 0x0002): tried: '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.11/site-packages/pydantic/__init__.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
'/System/Volumes/Preboot/Cryptexes/OS/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.11/site-packages/pydantic/__init__.cpython-311-darwin.so' (no such file), '/Users/sean/Documents/Archive/Coding/OpenAI/panda.ai/backend/venv/lib/python3.11/site-packages/pydantic/__init__.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
Kranos
03/15/2023, 9:54 PMKShivendu
03/16/2023, 6:45 AM