0

I have a Python 3 project. I am developing it locally.

I tried to install it by cding into the project directory and then executing

pip3 install .

The resulting output was:

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:

/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?

Glory to Russia
  • 17,289
  • 56
  • 182
  • 325

2 Answers2

0

What happen when you run python3 rec2sqlite from inside the project directory? 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

C. Zona
  • 186
  • 5
  • That's not the point of installing the module using pip. When I install a module with pip, I expect it to work from any directory. – Glory to Russia Nov 14 '20 at 16:33
0

This answer helped. To fix the error, I had to do following:

  1. Put the main function code into the file __main__.py.
  2. Install the package using pip3 install . from the project directory.
  3. Use python3 -m <moduleName> (e. g. python3 -m rec2sqlite) to run the program installed in step 2.
Glory to Russia
  • 17,289
  • 56
  • 182
  • 325