Forums

What is the difference between running in cmd and python files?

I was trying to serve a web page made with django.

However, an error occurred when running the Python code, but no error occurred when running it from the console of pythonanywhere.

For reference, no error occurred when running in the local environment.

The part where the error occurs is where 'xgboost' was used, and I wonder if the error occurs even though the settings are the same because there is some change in the environment.

I can't think of any differences between the way we run websites and the way we run commands that would cause issues with that. What is the most recent error at the bottom of your website's error log? There's a link to it on the "Web" page.

subprocess.CalledProcessError: Command '['python', 'folder2/folder2/python/predict.py', '--numbers', '[1.0,1.0,1.0,1.0]']' returned non-zero exit status 1.

The error occurs in Django's views.py, which runs Python as a subprocess.

What I'm curious about is whether it's normal when I run it from the bash console, but whether an error occurs when I run it by pressing run in the python file.

The error that occurs appears to be a library problem, not a path problem, so it is the same virtual environment.

I found a hint, and when I printed the version of xgboost in views.py and checked the version of xgboost in the Python folder I wanted to run, the versions were different.

That sounds like you are running those it 2 different environments. Perhaps different Python versions or different virtualenvs.