Если вы «установите» свой модуль Python, вы сможете это сделать.
Это предполагает, что вы все еще хотите иметь возможность редактировать свой код, где бы он ни находился на вашем локальном компьютере:
# doing it in a non-global way (i.e., just for the current user)
# from the directory containing your "setup.py" file
pip install --user -e .
# and as long as ~/.local/bin is in your path:
mycode
Если вы хотите сделать его доступным для каждого пользователя на машине,
# install an "editable" copy of the code from the current directory
# into the global Python installation
pip install -e .
# this will install it next to pip and your other Python tools
mycode
Обратите внимание, что вам не нужно указывать main в вашей настройке.пи либо:
entry_points = {'gui_scripts': ['mycode = mycode:main',],},