devika icon indicating copy to clipboard operation
devika copied to clipboard

unsupported operand type(s) for |: 'type' and 'type'

Open darrassi1 opened this issue 1 year ago • 5 comments

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

darrassi1 avatar Apr 02 '24 13:04 darrassi1

how did this error occur?

obliviousz avatar Apr 02 '24 13:04 obliviousz

how did this error occur?

When I run Devika for the first time

darrassi1 avatar Apr 02 '24 13:04 darrassi1

@darrassi1 Doesnt help much, can you tell me the exact place?

python3 devika.py? or bun run dev? And line number. Can you send the full error.

obliviousz avatar Apr 02 '24 14:04 obliviousz

@darrassi1 Doesnt help much, can you tell me the exact place?

python3 devika.py? or bun run dev? And line number. Can you send the full error.

python devika.py

darrassi1 avatar Apr 02 '24 14:04 darrassi1

It'd really help if you provide me with more context about the error. Send the full error

obliviousz avatar Apr 02 '24 15:04 obliviousz

I had the same problem on the 6th step of the installation in (Windows 10):

Start the Devika server:

python devika.py

Check which python -V version you're using.

The TypeError: unsupported operand type(s) for |: 'type' and 'type' error is actually related to the syntax used in type hints.

This specific syntax, using the pipe (|) for union types, was introduced in Python 3.10 as a part of PEP 604.

The error suggests that our environment is using Python < 3.10, which does not support this syntax

I solved by upgrading python to the latest stable version 3.11.9

Then you will need to:

# Deactivate the current virtual environment
deactivate

# Remove the old virtual environment folder
Remove-Item venv -Recurse

# Create a new virtual environment with the updated Python version
python -m venv venv

# Activate the new virtual environment
.\venv\Scripts\Activate

# Reinstall the dependencies
pip install -r requirements.txt

hope it helps! Lets Keep Coding 😎💻

DavidBendahan avatar Apr 03 '24 13:04 DavidBendahan