question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python 3.8 - "TypeError: expected string or bytes-like object" with poetry install

See original GitHub issue
  • 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.

py38 run-test: commands[0] | poetry install -vvv --extras all
Using virtualenv: /builds/yaal/sheraf/.tox/py38
[TypeError]
expected string or bytes-like object
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/local/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/local/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/local/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/usr/local/lib/python3.8/site-packages/poetry/console/commands/install.py", line 47, in handle
    installer = Installer(
  File "/usr/local/lib/python3.8/site-packages/poetry/installation/installer.py", line 55, in __init__
    installed = self._get_installed()
  File "/usr/local/lib/python3.8/site-packages/poetry/installation/installer.py", line 488, in _get_installed
    return InstalledRepository.load(self._env)
  File "/usr/local/lib/python3.8/site-packages/poetry/repositories/installed_repository.py", line 26, in load
    package = Package(name, version, version)
  File "/usr/local/lib/python3.8/site-packages/poetry/packages/package.py", line 42, in __init__
    self._name = canonicalize_name(name)
  File "/usr/local/lib/python3.8/site-packages/poetry/utils/helpers.py", line 26, in canonicalize_name
    return _canonicalize_regex.sub("-", name).lower()
ERROR: InvocationError for command /usr/local/bin/poetry install -vvv --extras all (exited with code 1)

Thank you for your help

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:20
  • Comments:33 (7 by maintainers)

github_iconTop GitHub Comments

54reactions
corderycommented, Feb 18, 2020

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)
....
36reactions
djackson-exo-inccommented, Feb 25, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"expected string or bytes-like object" on poetry install #3628
TypeError expected string or bytes-like object at ... First, I start with a pyenv -installed python-3.8.8: $ pyenv install 3.8.8 $ pyenv ...
Read more >
Notebooks/script don't recognize project package using poetry
If I run poetry install and try to import anything from source, whether it's from the ... TypeError expected string or bytes-like object...
Read more >
How to Fix: Typeerror: expected string or bytes-like object
This error typically occurs when you attempt to use the re.sub() function to replace certain patterns in an object but the object you're...
Read more >
Typeerror: Expected String Or Bytes-Like Object - ADocLib
The simplest solution is to apply Python str function to the column you are trying to loop through. If you are using pandas...
Read more >
How to install the dependencies of the submodule using poetry?
I have installed the dependencies required for my-project using poetry add ... Link to docs: https://python-poetry.org/docs/dependency-specification/#path- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found