V
V
veydlin2020-08-06 03:03:41
linux
veydlin, 2020-08-06 03:03:41

How to run python application in linux?

There is a Web server project in pycharm which has the following structure

[WebServer]
---- config.py
---- [app]
-------- __init__.py
-------- ...
-------- ...


In pycharm, the project starts normally with __init__.py

But when I tried to run __init__.py from the console in Linux, I got an error
Traceback (most recent call last):
File "__init__.py", line 5, in
from config import Config
ModuleNotFoundError: No module named 'config'


Okay, I thought, and threw config.py into the app folder and got an error
Traceback (most recent call last):
File "__init__.py", line 16, in
from app import routes, api, models
ModuleNotFoundError: No module named 'app'


those. do I need to somehow run the entire WebServer folder? At the same time, so that he understands that the app folder contains __init__.py from which it is necessary to start

How to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2020-08-06
@veydlin

Because these modules are not in PYTHONPATH, you need to sit down once, read the docs and figure out how to do everything right https://docs.python.org/3/tutorial/modules.html#th... and maybe for a deeper dive into topic https://docs.python.org/3/reference/import.html#th...

A
Andrey, 2020-08-06
@Andryxans

Perhaps in pycharm you are using an environment (venv) in which some modules are installed that were installed, for example, via pip install. In order for your project to work successfully, you need to create the same environment for it in Linux. To see what is installed in pycharm in the terminal, type: pip freeze - a list of installed packages will appear. also on linux try this command (must have pip installed) and compare the packages. If not, you'll have to dig deeper.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question