pip install –editable cause "running develop, error in 'egg_base' option: 'src' does not exist"
Question:
I tried to install my own python application via pip3 install --editable
. But I got an error like "running develop, error in 'egg_base' option: 'src' does not exist
".
The project has a src
folder layout.
hyperorg
├── docs
├── README.md
├── src
│ ├── hyperorg
│ │ ├── __init__.py
│ │ └── __main__.py
│ ├── setup.cfg
│ └── setup.py
└── tests
I did pip3 install --editable src
in folder hyperorg
and pip3 install --editable .
in folder hyperorg/src
without a noticeable difference.
The setup.py
just call setuptools.setup()
.
Here are some lines from the setup.cfg
which I build based on the official documentatoin.
[options]
package_dir=
=src
packages = find:
zip_safe = False
install_requires =
orgparse
[options.packages.find]
where = src
exclude =
docs*
tests*
notes
.gitignore
Full error output
$ pip3 install --editable src
Obtaining file:///home/user/tab-cloud/hyperorg/src
Requirement already satisfied: orgparse in /usr/local/lib/python3.9/dist-packages (from Hyperorg==0.0.0a1) (0.3.1)
Installing collected packages: Hyperorg
Running setup.py develop for Hyperorg
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/user/tab-cloud/hyperorg/src/setup.py'"'"'; __file__='"'"'/home/user/tab-cloud/hyperorg/src/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
cwd: /home/user/tab-cloud/hyperorg/src/
Complete output (2 lines):
running develop
error: error in 'egg_base' option: 'src' does not exist or is not a directory
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/user/tab-cloud/hyperorg/src/setup.py'"'"'; __file__='"'"'/home/user/tab-cloud/hyperorg/src/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
I wonder what running develop
means.
Answers:
The location of the setup.cfg
and setup.py
files are the problem here.
Depending on experiences with another project out of habit I located them in the src
folder.
hyperorg
├── src
│ ├── hyperorg
│ │ └── ...
│ ├── setup.cfg
│ └── setup.py
This can work in some circumstances but the official setuptools documentation about usage of setup.cfg
also state to locate that files in the project root like this.
hyperorg
├── src
│ └── ...
├── setup.cfg
└── setup.py
In that case my setup work like a charm without modifying any other files. I just have to do in the project root
pip3 install --editable .
The string develop
in the error output points to a Development Mode of setuptools
. This is because of the --editable
option in the pip
call. The effect of Development Mode is that the package is not installed the usual way via coping the py files in the right directories of the system but just links to the source folders are created.
EDIT: This answer is still valid. But keep in mind that today the recommendation is to use a pyproject.toml
file instead of setup.cfg
. The details can be found in the setuptools
docu.
I tried to install my own python application via pip3 install --editable
. But I got an error like "running develop, error in 'egg_base' option: 'src' does not exist
".
The project has a src
folder layout.
hyperorg
├── docs
├── README.md
├── src
│ ├── hyperorg
│ │ ├── __init__.py
│ │ └── __main__.py
│ ├── setup.cfg
│ └── setup.py
└── tests
I did pip3 install --editable src
in folder hyperorg
and pip3 install --editable .
in folder hyperorg/src
without a noticeable difference.
The setup.py
just call setuptools.setup()
.
Here are some lines from the setup.cfg
which I build based on the official documentatoin.
[options]
package_dir=
=src
packages = find:
zip_safe = False
install_requires =
orgparse
[options.packages.find]
where = src
exclude =
docs*
tests*
notes
.gitignore
Full error output
$ pip3 install --editable src
Obtaining file:///home/user/tab-cloud/hyperorg/src
Requirement already satisfied: orgparse in /usr/local/lib/python3.9/dist-packages (from Hyperorg==0.0.0a1) (0.3.1)
Installing collected packages: Hyperorg
Running setup.py develop for Hyperorg
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/user/tab-cloud/hyperorg/src/setup.py'"'"'; __file__='"'"'/home/user/tab-cloud/hyperorg/src/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
cwd: /home/user/tab-cloud/hyperorg/src/
Complete output (2 lines):
running develop
error: error in 'egg_base' option: 'src' does not exist or is not a directory
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/user/tab-cloud/hyperorg/src/setup.py'"'"'; __file__='"'"'/home/user/tab-cloud/hyperorg/src/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
I wonder what running develop
means.
The location of the setup.cfg
and setup.py
files are the problem here.
Depending on experiences with another project out of habit I located them in the src
folder.
hyperorg
├── src
│ ├── hyperorg
│ │ └── ...
│ ├── setup.cfg
│ └── setup.py
This can work in some circumstances but the official setuptools documentation about usage of setup.cfg
also state to locate that files in the project root like this.
hyperorg
├── src
│ └── ...
├── setup.cfg
└── setup.py
In that case my setup work like a charm without modifying any other files. I just have to do in the project root
pip3 install --editable .
The string develop
in the error output points to a Development Mode of setuptools
. This is because of the --editable
option in the pip
call. The effect of Development Mode is that the package is not installed the usual way via coping the py files in the right directories of the system but just links to the source folders are created.
EDIT: This answer is still valid. But keep in mind that today the recommendation is to use a pyproject.toml
file instead of setup.cfg
. The details can be found in the setuptools
docu.