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

./manage.py shell_plus --notebook failing with "AttributeError: 'PosixPath' object has no attribute 'startswith'" #1838

Open
patrickhoebeke opened this issue Sep 19, 2023 · 1 comment

Comments

@patrickhoebeke
Copy link

Hello,

I have some troubles using the command
./manage.py shell_plus --notebook

Its seems there are some incompatibility issues but I could not figure the root cause. Is this a bug ?

./manage.py shell_plus --notebook
Using selector: EpollSelector
Traceback (most recent call last):
  File "/home/pho/sources/personal/django/lecaillouvoyageur/./manage.py", line 22, in <module>
    main()
  File "/home/pho/sources/personal/django/lecaillouvoyageur/./manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django_extensions/management/commands/shell_plus.py", line 125, in run_from_argv
    return super().run_from_argv(argv)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django_extensions/management/utils.py", line 62, in inner
    ret = func(self, *args, **kwargs)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django_extensions/management/commands/shell_plus.py", line 582, in handle
    runner()
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django_extensions/management/commands/shell_plus.py", line 304, in run_notebook
    self.run_notebookapp(app_init, options, use_kernel_specs)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django_extensions/management/commands/shell_plus.py", line 251, in run_notebookapp
    app = app_init(notebook_arguments)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/django_extensions/management/commands/shell_plus.py", line 300, in app_init
    app.initialize(*args, **kwargs)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/notebook/notebookapp.py", line 2163, in initialize
    super().initialize(argv)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/jupyter_core/application.py", line 256, in initialize
    self.parse_command_line(argv)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/notebook/notebookapp.py", line 1633, in parse_command_line
    super().parse_command_line(argv)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/traitlets/config/application.py", line 883, in parse_command_line
    self.cli_config = deepcopy(loader.load_config())
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/traitlets/config/loader.py", line 883, in load_config
    self._parse_args(argv)
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/traitlets/config/loader.py", line 942, in _parse_args
    to_parse = [_replace(a) for a in to_parse]
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/traitlets/config/loader.py", line 942, in <listcomp>
    to_parse = [_replace(a) for a in to_parse]
  File "/home/pho/.virtualenvs/django/lib/python3.10/site-packages/traitlets/config/loader.py", line 931, in _replace
    if arg.startswith(k + "="):
AttributeError: 'PosixPath' object has no attribute 'startswith'

Here is the result of my pip freeze:

anyio==4.0.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asgiref==3.7.2
asttokens==2.4.0
async-lru==2.0.4
attrs==23.1.0
Babel==2.12.1
backcall==0.2.0
beautifulsoup4==4.12.2
black==23.9.1
bleach==6.0.0
cachetools==5.3.1
certifi==2023.7.22
cffi==1.15.1
chardet==5.2.0
charset-normalizer==3.2.0
click==8.1.7
colorama==0.4.6
comm==0.1.4
crispy-bootstrap4==2022.1
debugpy==1.8.0
decorator==5.1.1
defusedxml==0.7.1
distlib==0.3.7
Django==4.2.5
django-crispy-forms==2.0
django-debug-toolbar==4.1.0
django-extensions==3.2.3
django-geojson==4.0.0
django-leaflet==0.29.0
django-resized==1.0.2
django-widget-tweaks==1.5.0
entrypoints==0.4
exceptiongroup==1.1.3
executing==1.2.0
fastjsonschema==2.18.0
filelock==3.12.4
fqdn==1.5.1
GDAL==3.4.3
geographiclib==2.0
geopy==2.4.0
humanize==4.8.0
idna==3.4
ipykernel==6.25.2
ipython==8.15.0
ipython-genutils==0.2.0
isoduration==20.11.0
jedi==0.19.0
Jinja2==3.1.2
json5==0.9.14
jsonpointer==2.4
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
jupyter-events==0.7.0
jupyter-lsp==2.2.0
jupyter_client==7.4.8
jupyter_core==5.3.1
jupyter_server==2.7.3
jupyter_server_terminals==0.4.4
jupyterlab==4.0.6
jupyterlab-pygments==0.2.2
jupyterlab_server==2.25.0
MarkupSafe==2.1.3
matplotlib-inline==0.1.6
mistune==3.0.1
mypy-extensions==1.0.0
nbclassic==1.0.0
nbclient==0.8.0
nbconvert==7.8.0
nbformat==5.9.2
nest-asyncio==1.5.8
notebook==6.5.6
notebook_shim==0.2.3
numpy==1.25.2
overrides==7.4.0
packaging==23.1
pandocfilters==1.5.0
parso==0.8.3
pathspec==0.11.2
pexpect==4.8.0
pickleshare==0.7.5
Pillow==10.0.0
platformdirs==3.10.0
pluggy==1.3.0
prometheus-client==0.17.1
prompt-toolkit==3.0.39
psutil==5.9.5
ptyprocess==0.7.0
pure-eval==0.2.2
pycparser==2.21
Pygments==2.16.1
pyproject-api==1.6.1
python-dateutil==2.8.2
python-json-logger==2.0.7
PyYAML==6.0.1
pyzmq==24.0.1
referencing==0.30.2
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.10.3
Send2Trash==1.8.2
six==1.16.0
sniffio==1.3.0
soupsieve==2.5
sqlparse==0.4.4
stack-data==0.6.2
terminado==0.17.1
tinycss2==1.2.1
tomli==2.0.1
tornado==6.3.3
tox==4.11.3
traitlets==5.10.0
typing_extensions==4.7.1
uri-template==1.3.0
urllib3==2.0.4
virtualenv==20.24.5
wcwidth==0.2.6
webcolors==1.13
webencodings==0.5.1
websocket-client==1.6.3

Any help is welcome :-)

@patrickhoebeke
Copy link
Author

I found the root cause thanks to this post:
https://groups.google.com/g/django-users/c/nrLxVflwTjY/m/MZEm4fc1BAAJ

Apparently, in the settings.py, you should not use something like:
BASE_DIR / 'someothervalue'
but rather
os.path.join(BASE_DIR, "someothervalue")

So, I am not sure wheter django-extension is concerned by this issue.
I leave to the experts the decision to close this issue ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant