-
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
Python 3.8 - "TypeError: expected string or bytes-like object" with poetry install #2027
Comments
Hi, I experience the same issue, and eventually traced it to this: class InstalledRepository(Repository):
@classmethod
def load(cls, env): # type: (Env) -> InstalledRepository
"""
Load installed packages.
For now, it uses the pip "freeze" command.
"""
repo = cls()
seen = set()
print(env.sys_path)
for entry in env.sys_path:
if not entry:
continue
print('entry', repr(entry))
e.g. at this point env.sys_path contains an empty string as the first item, which somehow eventually leads to 'name' passed to canonicalize_name being None |
Seeing the exact same issue, but on Python 3.7.2 and poetry 1.0.3. Downgrading to poetry 1.0.2 made no difference. |
I think this is caused by a bug in virtualenv like mentioned in #1953. This is fixed in the latest release of virtualenv. |
This will also happen if you somehow end up with an .egg-info file (presumably malformatted) in your project directory. I think I created one unintentionally while experimenting with dephell, but regardless of the source this is what you can expect to see: myproject % touch myproject.egg-info
myproject % poetry check
All set!
myproject % poetry show
[TypeError]
expected string or bytes-like object
myproject % rm myproject.egg-info
myproject % poetry show
aiohttp 3.6.2 Async http client/server framework (asyncio)
.... |
@cordery thank you, man. that was sick. |
For me it was also due to activated conda environment. So it was fixed by |
@trim21 can you raise a new issue with some additional details please? Maybe a pyproject.toml, |
@abn OK, I'll create a repo with github actions to reproduce it. |
Same issue |
@trim21 Is there a link to your repo? |
@cordery Also confirm this was due to a bad egg for me. I deleted the |
@adam-grant-hendry; yes I think this is because we moved to a in-tree editable installer (1.1) rather than relying on setuptools (1.0). The old egg-info takes precedence when python path is built i think. |
Not yet, being busy these days.
…------------------ Original ------------------
From: "adam-grant-hendry"<[email protected]>;
Date: 2020年10月7日(星期三) 凌晨4:06
To: "python-poetry/poetry"<[email protected]>;
Cc: "Trim21"<[email protected]>; "Mention"<[email protected]>;
Subject: Re: [python-poetry/poetry] Python 3.8 - "TypeError: expected string or bytes-like object" with poetry install (#2027)
@trim21 Is there a link to your repo?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@AmmarlOsama It has been fixed in latest poetry. |
Hitting this on a fresh project, with 1.1.4 latest release installed via pip edit: I commented out a git dep and now it let me |
@repnop |
@sinoroc its an internal work project so the git dependency is not public, but its a simple dep = { git = "git://a.url/dep" } the full error is exactly the same as above, and I did hit it when trying to install |
Same here. I can't get to workaround this with a git dependency. |
Also the same (git dependency) -- made sure I have most recent virtualenv, and deleted the old virtualenv, but still didn't work with reported error. Pyproject.toml as follows:
|
My idea is that this error will occur allways if the name of installed package is missing for poetry. I want install some package shared between my projects on the development machine (something like -e mode of pip). I create empty mypackage/ and inside mypackage/mypackage/ with code. Now: Both Then I create Minimum
Maybe this will help to identify the reasons more exactly? |
What is the solution to this? This ticket is closed, but I am still getting the issue. I have read every comment here and did not see what allowed this to be closed. If this is fixed in some version of poetry, can someone please be explicit about which specific version of poetry this is fixed in? Thank you. |
On my machine, this was fixed when I installed Poetry version 1.1.5. |
Don't know why this issue is closed but still exists in version 1.1.5. |
In my case, I moved pyproject.toml to the root directory of the git repository and that fixed the problem. OKgit repository root/ NGgit repository root/ (repository = GitHub repository of poetry package) |
For people looking for an open issue related to this, the discussion seems to continue here: #3628 |
This issue still exists in the latest 1.1.7 |
I solved this problem by deleting the virtual environment. First you can get ENV_NAME by typing |
Nuking and recreating the env did it for me too. I did hit CTRL+C in the middle of an install before this problem began. I guess I'm naive to think that'd be safe. |
I was encountering this issue within the build phase of a dockerized Django web app. I made a few changes to my Dockerfile which fixed this issue for me. Unfortunately I'm not fully clear on which change fixed it. I suspect it's that in poetry v1.x.x the lack of virtualenvs is configured via
|
For everyone still having issues with this, also with Python 3.9, this could also work (worked for me): poetry export --without-hashes > requirements.txt
pip install -r requirements.txt Or in Docker: ...
RUN pip install --upgrade pip
RUN pip install poetry
COPY pyproject.toml .
COPY poetry.lock .
RUN poetry export --without-hashes > requirements.txt \
&& pip install -r requirements.txt |
Deleting the single *.egg from my .../python3.*/site-packages/ directory fixed this error. |
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. |
I am on the latest Poetry version.
I have searched the issues of this repo and believe that this is not a duplicate.
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).OS version and name: gitlab python3.8 docker image
Poetry version: 1.0.3
Link of a Gist with the contents of your pyproject.toml file: gitlab-ci report
Issue
I have a project using poetry that use Gitlab-CI and tox to run tests in several environments. The very same code works in python 3.5, 3.6 and 3.7, but produce the following error with python 3.8. The error message is not very clear so I am not sure what is going on.
You can view all the successful executions here and the failing one here. If it matters, you can see the tox configuration here and the poetry configuration here.
Thank you for your help
The text was updated successfully, but these errors were encountered: