You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to specify the installation of the current directory, which causes a ModuleNotFoundError #456
I believe the issue is as follows: The connect server does not install packages from the local directory (through setup.py or pyproject.toml.), but only what is in requirements. In the manifest.json, the files from my_awesome_package are specified, but they cannot be found because the package has not been installed.
Question
How can I specify through rsconnect that the current directory should also be installed? Could this be an update to the manifest, or is there another way of doing it?
setuptools.extern.packaging.requirements.InvalidRequirement: Expected package name at the start of dependency specifier
.
^
[end of output]
Workaround 1
A workaround can be to remove the dynamic dependencies from pyproject.toml and keeping . in requirements.txt:
[project]
name = "my-awesome-package"version = "0.0.0"
Now the installation works. However, when changing your code and redeploying to connect, the cached environment is used.
Workaround 2
This builds on the workaround above:
Specify -e . in requirements.txt. This makes the installation of the current directory editable (so changes are passed to the Connect server). It also allows cached environments to still be used, as long as your requirements don't change.
Drawback
The major drawback is that you cannot install your application including dependencies anymore with:
pip install .# or
pip install -e .
It now requires a different (and less clear) installation:
pip install -r requirements.txt
Conclusion
Found a workaround. It works but isn't ideal. Would be awesome if Connect Server would support pyproject.toml, not just requirements.txt. But I guess this is not up to rsconnect-python!
Thank you for the detailed writeup! I'm glad you were able to find a workaround. It can be tricky when the project includes both a package and a consumer of the package. As you've noted, Connect's environment caching will not build a new environment when the package changes, unless the reference to it in requirements.txt changes. The approach of using an editable installation might cause some side effects if another project uses the environment (because it has the same content in requirements.txt).
Another option would be to put the package directory in the same directory as the app and import from there, rather than listing it as a dependency. Or, if you have access to a local/private PyPI compatible repo, you can publish the package there and reference it as a dependency.
🤖 Since 1.33.0 (#931), if your package is installed in editable mode (pip install -e .) inside the deployment directory, rsconnect write-manifest … --force-generate / rsconnect deploy … --force-generate writes it to requirements.txt as -e ., so Connect installs your project with its dependencies. You no longer need a hand-written requirements file that conflicts with dynamic dependencies in pyproject.toml. We checked this locally with a src-layout package and a Streamlit entrypoint. Closing as completed. If this still doesn't work for your layout, please reopen with the generated requirements.txt.
Activity
timotk commentedon Jul 27, 2023
Specify . in requirements.txt
One option is to specify
.in therequirements.txt, installing the current directory:However, this conflicts with my
pyproject.toml, which specifies dependencies dynamically:The error now becomes:
setuptools.extern.packaging.requirements.InvalidRequirement: Expected package name at the start of dependency specifier . ^ [end of output]Workaround 1
A workaround can be to remove the dynamic dependencies from
pyproject.tomland keeping.inrequirements.txt:Now the installation works. However, when changing your code and redeploying to connect, the cached environment is used.
Workaround 2
This builds on the workaround above:
Specify
-e .in requirements.txt. This makes the installation of the current directory editable (so changes are passed to the Connect server). It also allows cached environments to still be used, as long as your requirements don't change.Drawback
The major drawback is that you cannot install your application including dependencies anymore with:
It now requires a different (and less clear) installation:
Conclusion
Found a workaround. It works but isn't ideal. Would be awesome if Connect Server would support
pyproject.toml, not justrequirements.txt. But I guess this is not up torsconnect-python!mmarchetti commentedon Jul 27, 2023
Thank you for the detailed writeup! I'm glad you were able to find a workaround. It can be tricky when the project includes both a package and a consumer of the package. As you've noted, Connect's environment caching will not build a new environment when the package changes, unless the reference to it in
requirements.txtchanges. The approach of using an editable installation might cause some side effects if another project uses the environment (because it has the same content inrequirements.txt).Another option would be to put the package directory in the same directory as the app and import from there, rather than listing it as a dependency. Or, if you have access to a local/private PyPI compatible repo, you can publish the package there and reference it as a dependency.
tdstein commentedon Nov 10, 2026
🤖 Since 1.33.0 (#931), if your package is installed in editable mode (
pip install -e .) inside the deployment directory,rsconnect write-manifest … --force-generate/rsconnect deploy … --force-generatewrites it torequirements.txtas-e ., so Connect installs your project with its dependencies. You no longer need a hand-written requirements file that conflicts with dynamic dependencies inpyproject.toml. We checked this locally with a src-layout package and a Streamlit entrypoint. Closing as completed. If this still doesn't work for your layout, please reopen with the generatedrequirements.txt.