Skip to content
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

'list' object has no attribute 'is_python' error when initialising new project #110

Closed
1 task done
rbpatt2019 opened this issue Apr 15, 2020 · 5 comments
Closed
1 task done
Labels
🐛 bug Something isn't working ⬆️ upstream bug Caused by a bug from the upstream dependencies

Comments

@rbpatt2019
Copy link

  • I have searched the issue tracker and believe that this is not a duplicate.

Running pdm init in any directory yields a AttributeError: 'list' object has no attribute 'is_python' error.

Steps to reproduce

After installing pdm using:

pipx install pdm

Attempt to initialise a new project using the following:

mkdir pdm-test && cd pdm-test
pdm init -v

Actual behavior

pdm init -v fails with the following error, regardless of the directory or Python interpreter:

Creating a pyproject.toml for PDM...
Please enter the Python interpreter to use: 3.7
Traceback (most recent call last):
  File "/Users/pattersonrb/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pdm/core.py", line 68, in __call__
    return self.main(*args, **kwargs)
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pdm/core.py", line 100, in main
    raise err.with_traceback(traceback)
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pdm/core.py", line 96, in main
    f(options.project, options)
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pdm/cli/commands/init.py", line 32, in handle
    actions.do_use(project, python)
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pdm/cli/actions.py", line 384, in do_use
    for i, entry in enumerate(finder.find_all_python_versions(*args)):
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/pythonfinder.py", line 323, in find_all_python_versions
    major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch, name=name
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 548, in find_all_python_versions
    values = list(self.get_pythons(sub_finder))
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 506, in get_pythons
    pythons = [entry for entry in self._get_all_pythons(finder)]
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 506, in <listcomp>
    pythons = [entry for entry in self._get_all_pythons(finder)]
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 499, in _get_all_pythons
    for python in self._filter_paths(finder):
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 491, in _filter_paths
    python_versions = finder(path)
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/python.py", line 289, in find_all_python_versions
    pythons = [p for p in pythons if p and p.is_python and p.as_python is not None]
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/python.py", line 289, in <listcomp>
    pythons = [p for p in pythons if p and p.is_python and p.as_python is not None]
AttributeError: 'list' object has no attribute 'is_python'

Expected behavior

A new project should be initiated.

Environment Information

pdm version: 0.7.1

Python Interpreter: /Users/pattersonrb/.pyenv/shims/python (3.7.7)
Project Root:       /Users/pattersonrb/projects/pdm-test
{
  "implementation_name": "cpython",
  "implementation_version": "3.7.7",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "19.3.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64",
  "python_full_version": "3.7.7",
  "platform_python_implementaiton": "CPython",
  "python_version": "3.7",
  "sys_platform": "darwin"
}

Additionally,

>>> pyenv versions
  system
* 3.7.7 (set by /Users/pattersonrb/.pyenv/version)
  3.8.2

Though both 3.7 and 3.8 return the error.

Super excited to see this tool develop!

@rbpatt2019 rbpatt2019 added the 🐛 bug Something isn't working label Apr 15, 2020
@frostming
Copy link
Collaborator

The issue lies deeply in the 3rd party package, I need your assistance for debugging, can you do the following?

  1. Activate the venv where pdm is installed
  2. import pythonfinder
    finder = pythonfinder.Finder()
    print(list(finder.find_all_python_versions(3, 7))

@frostming frostming added the ⬆️ upstream bug Caused by a bug from the upstream dependencies label Apr 16, 2020
@rbpatt2019
Copy link
Author

It is indeed deep in the dependencies! Activating the virtualenv containing pdm and running the above returns:

>>> import pythonfinder
>>> finder = pythonfinder.Finder()
>>> print(list(finder.find_all_python_versions(3, 7))
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/pythonfinder.py", line 323, in find_all_python_versions
    major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch, name=name
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 548, in find_all_python_versions
    values = list(self.get_pythons(sub_finder))
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 506, in get_pythons
    pythons = [entry for entry in self._get_all_pythons(finder)]
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 506, in <listcomp>
    pythons = [entry for entry in self._get_all_pythons(finder)]
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 499, in _get_all_pythons
    for python in self._filter_paths(finder):
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/path.py", line 491, in _filter_paths
    python_versions = finder(path)
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/python.py", line 289, in find_all_python_versions
    pythons = [p for p in pythons if p and p.is_python and p.as_python is not None]
  File "/Users/pattersonrb/.local/pipx/venvs/pdm/lib/python3.7/site-packages/pythonfinder/models/python.py", line 289, in <listcomp>
    pythons = [p for p in pythons if p and p.is_python and p.as_python is not None]
AttributeError: 'list' object has no attribute 'is_python'

pythonfinder also has a CLI. Again, after activating the virtualenv, I can run the following from the command line...

$ python3 -m pythonfinder --findall
Found python at the following locations:
3.8.2: 3.8.2 (None) @ /Users/xxx/.pyenv/versions/3.8.2/bin/python3
python3: 3.7.7 (None) @ /Users/xxx/.local/pipx/venvs/pdm/bin/python3
python3: 3.7.7 (None) @ /Users/xx/.local/pipx/venvs/pdm/bin/python3
3.7.7: 3.7.7 (None) @ /Users/xx/.pyenv/versions/3.7.7/bin/python3
python3: 3.7.3 (None) @ /usr/bin/python3
python2: 2.7.16 (None) @ /usr/bin/python2
python2.7: 2.7.16 (None) @ /usr/bin/python2.7

Which works exactly as expected. Those indeed are all the python versions on my system (user name redacted). This leads me to believe it's an issue with pythonfinder. Indeed, people have reported similar problems though they reported the bug fixed about a year and a half ago.

So it seems the issue is in pythonfinder, not pdm. If you'd like, I can create an issue over there, or you can do so. Let me know! Either way, you can close this if you'd like, as it's pretty clearly not a pdm issue!

@frostming
Copy link
Collaborator

I can create an issue over there

Please do it. I am also a maintainer of pythonfinder LOL.

@rbpatt2019
Copy link
Author

I'll close it here, then, so there aren't duplicate issues floating around. Thanks for the help!

@frostming
Copy link
Collaborator

frostming commented Apr 22, 2020

@rbpatt2019 I have published a bugfix release for pythonfinder, you can upgrade pdm to get it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working ⬆️ upstream bug Caused by a bug from the upstream dependencies
Projects
None yet
Development

No branches or pull requests

2 participants