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

No module named 'json' error #108

Open
kiedeng opened this issue Nov 18, 2024 · 6 comments
Open

No module named 'json' error #108

kiedeng opened this issue Nov 18, 2024 · 6 comments

Comments

@kiedeng
Copy link

kiedeng commented Nov 18, 2024

I have deployed the Sanbox local source code, and I have updated the python_path to the path of the Miniconda virtual environment (python_path=/root/miniconda3/envs/sanbox/bin/python). However, when I actually use it, it still reports a 'No module named 'json'' error
If I'm deploying with Miniconda, is this configuration not workable?

@zenorochaV1
Copy link

same

3 similar comments
@cabbage217
Copy link

same

@kkjinping
Copy link

same

@AegonT
Copy link

AegonT commented Dec 23, 2024

same

@18827555809
Copy link

18827555809 commented Dec 26, 2024

I have deployed the Sanbox local source code, and I have updated the python_path to the path of the Miniconda virtual environment (python_path=/root/miniconda3/envs/sanbox/bin/python). However, when I actually use it, it still reports a 'No module named 'json'' error If I'm deploying with Miniconda, is this configuration not workable?

I haven't tried your scenario, but I can roughly guess the reason for the problem, mainly related to the location of Python. When building the project, the Python related environment will be copied to/var/sandbox/sandbox-python. The location you provided is:/root/miniconda3/envs/sanbox/bin/python, So it will be copied to/var/sandbox/sandbox-python, and you need to check if there is/var/sandbox/sandbox-python/var/local/lib/python3.XX/site-packages under /var/sandbox/sandbox-python related dependencies

@AegonT
Copy link

AegonT commented Dec 27, 2024

I resolved this issue through the following steps:

Start the Image:
First, I launched the sandbox image to access the container environment:

docker start <container_name>
docker exec -it <container_name> /bin/bash

Modify the Default Python Path:
Inside the image, I located the system’s default Python path and changed it to the Python path installed in Miniconda. This ensures the container uses Miniconda’s Python environment instead of the system’s default Python.

Check the current Python path:

which python

Update the PATH environment variable to point to Miniconda’s Python:

export PATH="/path/to/miniconda/bin:$PATH"

Verify the change:

which python

Save the Changes:
To make the changes persistent, I updated the container’s configuration or saved it as a new image:

docker commit <container_id> <new_image_name>

Restart the Image:
Finally, I restarted the image to verify the modifications:

docker stop <container_name>
docker start <container_name>
docker exec -it <container_name> /bin/bash
which python  # Confirm the Python path is correctly set

By following this approach, I successfully switched the Python environment of the sandbox image to Miniconda, resolving the related issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants