[英]How can I start the main function of this Python module after installing it using pip?
I have a Python 3 project .我有一个 Python 3项目。 I am developing it locally.我正在本地开发它。
I tried to install it by cd
ing into the project directory and then executing我尝试通过cd
进入项目目录然后执行来安装它
pip3 install .
The resulting output was:结果 output 是:
Processing /Users/XXXXX/dev/misc/rec2sqlite
Building wheels for collected packages: rec2sqlite
Building wheel for rec2sqlite (setup.py) ... done
Created wheel for rec2sqlite: filename=rec2sqlite-1.0-py3-none-any.whl size=3758 sha256=77225f8b2444fb4143ffb2aa70ee22735eff591452ba777387cc10b42f21b6ac
Stored in directory: /private/var/folders/pt/7nsl9k8d6q56bwj9nc6lydzh0000gn/T/pip-ephem-wheel-cache-_voecun1/wheels/8b/47/6c/df4c285c608c63e5b3d6df78ec193cf038b3d4a56f4e3b2420
Successfully built rec2sqlite
Installing collected packages: rec2sqlite
Attempting uninstall: rec2sqlite
Found existing installation: rec2sqlite 1.0
Uninstalling rec2sqlite-1.0:
Successfully uninstalled rec2sqlite-1.0
Successfully installed rec2sqlite-1.0
Then I went to another directory and wanted to run the main function. I entered python3 rec2sqlite
and got the following output:然后进入另一个目录,想运行main function,输入python3 rec2sqlite
,得到如下output:
/usr/local/bin/python3: can't open file 'rec2sqlite': [Errno 2] No such file or directory
What do I need to change in the source code and/or the commands I use in order to be able to run the main function after installing the current version using pip
?在使用 pip 安装当前版本后,我需要更改源代码和/或我使用的命令才能运行主pip
?
What happen when you run python3 rec2sqlite
from inside the project directory?从项目目录中运行python3 rec2sqlite
时会发生什么? If you have to run the it from another directory you could try with the full path to the directory python3 /<path-to-project-directory>/rec2sqlite
如果您必须从另一个目录运行它,您可以尝试使用目录python3 /<path-to-project-directory>/rec2sqlite
的完整路径
This answer helped.这个答案有帮助。 To fix the error, I had to do following:要修复错误,我必须执行以下操作:
__main__.py
.将主要的 function 代码放入文件__main__.py
中。pip3 install.
使用pip3 install.
from the project directory.从项目目录。python3 -m <moduleName>
(eg python3 -m rec2sqlite
) to run the program installed in step 2.使用python3 -m <moduleName>
(例如python3 -m rec2sqlite
)运行在步骤 2 中安装的程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.