-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conda compatibility #105
Comments
I don't use miniconda so I don't know if I can be of much help here. However, you are doing it right so thre must be a bug somewhere. Which package does it say can't be found? And Can you do |
I suspect that has something to do with how poetry not perceiving conda as a virtualenv. The signs:
This is different compared to what poetry is doing when detecting venv with pipenv or virtualen. I think the culprit is that it's not configured or half configured to perceive conda env. Additional info:
|
@extraymond I will take a look at this and get back to you. |
@sdispater Thx! Looking forward to using poetry. |
Hi,
Installing a dep with conda will work fine (from condaforge):
All that works fine. Now, trying to add that package (after installing it with conda) yields:
The intersting part (I guess) is the message from poetry that says:
Meaning, that it did not identify the conda virtualenv. @sdispater could you maybe point us to the mechanisms of poetry to detect the virtualenvs ❓ so that we can maybe try out helping |
I found the reason. Because It modified the PATH in .bash_profile (or .zshrc your shell rc file) when installing Anaconda (or miniconda), something like this:
And when we run https://github.com/sdispater/poetry/blob/master/poetry/utils/env.py#L295 subprocess.call the shell and shell loads rc file, the anaconda/bin path alwasys at front of venv/bin path. so the python interpreter path is wrong. To fix this we cloud use https://github.com/pexpect/pexpect to spawn new shell and in new shell beginning to activate the venv, like pipenv do: https://github.com/pypa/pipenv/blob/master/pipenv/shells.py#L106-L107 This can make the venv bin path at the front of PATH 😂 |
I have made a tool on behalf of Eigen Technologies that integrates poetry into conda environments. It sidesteps the virtualenv and installs the poetry packages directly into the conda environment. We are using it to create, package, and deploy environments to clients. Any non-binary pip packages are compiled with conda's cross-compilers for maximum compatibility across OS versions/distros. You don't even need a conda environment file, its optional; using this tool you can zip up Poetry environments into a portable cross-distro/cross-version tarball It works for Linux and macOS only. https://github.com/eigentechnologies/cpip Check it out! Let me know if you have any suggestions. |
The latest releases of miniconda no longer modify the ~/.bashrc to add conda to the PATH. The latest releases use something like an /etc/profile.d/conda.sh to load bash functions (check it with There is a bit of a gulf between conda packaging and pure-pip packaging, including the package repositories that have inconsistent package names and versions. Attempting to get poetry to work with conda might be mission impossible and potentially misguided. AFAICT, the aim of poetry is compatible with pure-pip packaging, but it does not aim to replace the conda package specs in For my 2c, poetry is pure-pip and not conda compatible. If it tries to move into the conda domain, it could be a world of pain. If poetry detects a conda-env, it could run away and complain loudly about the misguided attempt to combine these two worlds of packaging systems. The responsibility to work with poetry might lie with conda and perhaps could include a clause in the environment.yml file to allow use of poetry as it does allow a pip clause now already. The bigger question is what to do about the conda channels vs. pypi repositories and the underlying dependency resolution engines and that might fall into the too-hard basket for a while. |
Heads up, stay away from PATH and the pyenv model until some shim problems are resolved, see pyenv/pyenv#1112 |
I followed these steps to install Conda and Poetry on Linux. These same steps should work for Mac as well (not sure about Windows):
bash Miniconda3-latest-Linux-x86_64.sh -p <CONDA-INSTALL-LOCATION>
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
poetry config settings.virtualenvs.path <CONDA-INSTALL-LOCATION>
conda create -n <MY-ENV-NAME> python=<PYTHON-VERSION>
conda activate <MY-ENV-NAME>
poetry install |
Programmatic attempt at ^^ @rmorshea (good tip)
Still, no idea whether conda can migrate to a |
In addition to the above, I had to configure poetry to not create a new virtualenv to use the conda env::
It seems like an inevitability that you are going use pip for something when using conda, so at the very least having the poetry wrapper over top is a bonus, as long as you're basically using conda as just a python vendor as @darrenleeweber describes. It seems like the "right" way to mix the two would be to create a CondaEnv and CondaInstaller that are somehow configurable within. I'm definitely not enough of a conda internals expert to attempt this though. Given the necessity of managing scientific and numerical dependencies for python projects it sure would be nice if there really was "one-- and preferably only one --obvious way to do it." |
On windows, I am using conda exclusively to manage different python versions and create virtual envs. Inside the virtual env I install everything via pip (akin to @darrenleeweber @ryanfeather). I can confirm that configuring poetry like @ryanfeather also works on windows. The only catch is to provide a path enclosed in quotes
|
None of the suggestions above (neither rmorshea nor ryanfeather) worked for me as expected. First, on Windows 10 Enterprise, I started with a fresh copy of the latest version of MiniConda and ran Default Conda Package List
Then, I installed poetry using the "curl and pipe to python" method and verified that the 'base' environment did not change. Then, I tried several different ways to install the basic "new" project. A. First try:
B. Second try (after reinstalling a fresh conda):
C. Third try (after reinstalling a fresh conda):
Every single attempt installed the packages into the base environment. Packages in 'simple' virtual environment:
Packages in base environment: Packages installed into "base" environment:
In the third attempt, even though the commands were executed in the 'simple' virtual environment, poetry installed all packages into the 'base' environment. |
Maybe poetry is assuming that the python installation has the 'virtualenvironment' package preinstalled? I would have thought that it's installed as part of the poetry setup or initialization. It seems to work if I install the module before trying to run poetry. |
It would be nice if poetry worked inside a conda environment as long you stayed pip-only. If we can make small tweaks that make the several-step manual process documented above easier, I'm all for that. Beyond that though, I tend to agree with @darrenleeweber that attempting compatibility between poetry and conda would be a world of pain and is perhaps not even possible. Outside of windows, pyenv is pretty decent at managing python versions and virtual environments. I wish there was some equivalent tool for windows. Maybe pyenv for windows will gain some traction? My recommendation is that:
|
In terms of poetry installing packages to the base conda environment despite being in a conda virtualenv, I have been able to avoid this somewhat by installing poetry from |
This issue should be solved by PR #1432 , shouldn't it? |
@finswimmer yes, it should be. That PR will be merged shortly so I will close this issue now. |
I don't think the PR fixed the I don't think this is working, speaking from Windows. Same thing as above happesn for pytest and anything else I'm trying to use in a poetry / conda project. poetry show -v with dependencies commented out:
poetry show -v with dependencies defined, numpy = "^1.17"
conda list with grep to look for a dependency installed in conda env under test
|
@sdispater I think everyone is missing a key point here: |
@adamgranthendry I was using dependencies = [
"tqdm",
"pqdm", #PyPI
"seaborn",
"pymatgen",
"scipy",
"hdbscan",
"cython", # for hdbscan 0.8.27 or similar
"numba>=0.53.1",
"plotly",
"python-kaleido",
"pandas",
"matplotlib>=3.4.3",
"joblib",
"ElMD==0.4.8", #PyPI
"psutil",
"scikit_learn",
"umap-learn",
"dill",
] Just now trying out |
Make sdist deterministic by setting gzip mtime to 0
https://pixi.sh/ is a package manager that is very similar to poetry, but supports conda natively. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi! I tried installing poetry alongside my miniconda env.
It's installed via the curl installer.
At first, it seems that package resolving and installing works.
When I try to run the script using:
It emit the error saying that package is not found, which can be found in
poetry show
.I'm not sure if this is actually conda related issue or just misuse of the CLI. Would be nice to know how I can get it working with poetry. Seems like a really nice project. Thx
The text was updated successfully, but these errors were encountered: