I am beginner in python. I created project with three .py files and one database file in PyCharm. But don`t understand how run my project via cmd console or something else. Do I need to create start class like "main" or what to do? How can I sent my project to another people that they may run it?
3 Answers
Python program does not require "main function" as entry point, each line of a .py file will be executed sequentially. All you need is to type: python yourprogram.py in your console.
But on the other hand, many people choose to have a "main function" in their python program and only invoke this function when python program is run as a stand-alone script as opposed to being loaded as a module.
def main():
# do something
if __name__ == "__main__":
main()
Comments
Each of your .py file is an executable. Depending on how you have coded, these files might be inter-dependent. In that case, there might be a main file(with any name, need not name it main.py, could be hello.py). So, you can run that file with python <filename>. As far as the language is concerned, there is no need to create a special class like main. Though you are free to do that.
General style it to include a statement in the end of the main file like suppose you have three files hello.py, bye.py, work.py, where
from work import *
from bye import *
def hello():
print "Hello"
if __name__ == "__main__":
hello()
You can run python hello.py
For sharing, you can create a zip of the folder and share that zip or you can create a git hub repository and share the github link.
The error is in opening the file. please check for spelling errors and the location of the db file

python script.pywherescriptis the name of the file... You ran the code fine, though. The database file can't be read. Note: python doesn't really usesrcfolder like in Java.pyscript as is in your PyCharm's configuration. Also ensure that you are using the same python installation as does PyCharm when you run through terminal and that. Finally PyCharm might be calling your file from withinContactBookdirectory rather thansrc. Which current working directory you are using is important, i.e. you might not be able to open files because your program is looking at them in the wrong folder because working directory doesn't match.srcwhen trying to opensrc\Contacts.db, i.e. it's trying to accessC:\Users\homic\PycharmProjects\ContactBook\src\src\Contacts.db.