What does "SyntaxError: invalid syntax" mean in an Odoo application? - python

I am facing below error in Odoo application:
"C:\Program Files (x86)\Odoo 12.0\python\python.exe" "C:/Program Files (x86)/Odoo 12.0/server/odoo-bin" -c D:\config_odoo\config.txt -d Duy123
Traceback (most recent call last):
File "C:/Program Files (x86)/Odoo 12.0/server/odoo-bin", line 5, in <module>
import odoo
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\__init__.py", line 125, in <module>
from . import modules
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\__init__.py", line 8, in <module>
from . import db, graph, loading, migration, module, registry
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\graph.py", line 10, in <module>
import odoo.tools as tools
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\__init__.py", line 9, in <module>
from .misc import *
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\misc.py", line 26, in <module>
import werkzeug.utils
File "C:\Program Files (x86)\Odoo 12.0\python\lib\site-packages\werkzeug\__init__.py", line 152, in <module>
__import__('werkzeug.exceptions')
File "C:\Program Files (x86)\Odoo 12.0\python\lib\site-packages\werkzeug\exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "C:\Program Files (x86)\Odoo 12.0\python\lib\site-packages\werkzeug\wrappers.py", line 26, in <module>
from werkzeug.http import HTTP_STATUS_CODES, \
File "C:\Program Files (x86)\Odoo 12.0\python\lib\site-packages\werkzeug\http.py", line 26, in <module>
from urllib2 import parse_http_list as _parse_list_header
File "C:\Program Files (x86)\Odoo 12.0\python\lib\site-packages\urllib2.py", line 220
raise AttributeError, attr
^
SyntaxError: invalid syntax
Process finished with exit code 1

This is a general Python error. It's telling you that there's an error in your module's code.
According to the logs, it seems like you're trying to use a module written for an older Odoo version into 0doo 12. In general terms, that's a bad idea, and you're seeing why.

Related

How Do I get rid of this error:Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program?

I keep trying to start my python backend with uvicorn main:app --reload but I keep getting this error:
INFO: Will watch for changes in these directories: ['C:\\Users\\darkg\\OneDrive\\Desktop\\loginpage\\FastAP_BackEnd\\books']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [532] using StatReload
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 126, in _main
self = reduction.pickle.load(from_parent)
File "C:\Users\darkg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\uvicorn\__init__.py", line 1, in <module>
from uvicorn.config import Config
File "C:\Users\darkg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\uvicorn\config.py", line 1, in <module>
import asyncio
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\asyncio\__init__.py", line 8, in <module>
from .base_events import *
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 18, in <module>
import concurrent.futures
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\_base.py", line 7, in <module>
import logging
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\logging\__init__.py", line 26, in <module>
import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\tokenize.py", line 35, in <module>
from token import *
File "C:\Users\darkg\OneDrive\Desktop\loginpage\FastAP_BackEnd\books\.\token.py", line 5, in <module>
from . import schemas
ImportError: attempted relative import with no known parent package
I tried starting it with python -m uvicorn main:app --reload
but I get this error instead
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "C:\Users\darkg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\uvicorn\__init__.py", line 1, in <module>
from uvicorn.config import Config
File "C:\Users\darkg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\uvicorn\config.py", line 1, in <module>
import asyncio
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\asyncio\__init__.py", line 8, in <module>
from .base_events import *
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 18, in <module>
import concurrent.futures
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\_base.py", line 7, in <module>
import logging
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\logging\__init__.py", line 26, in <module>
import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\tokenize.py", line 35, in <module>
from token import *
File "C:\Users\darkg\OneDrive\Desktop\loginpage\FastAP_BackEnd\books\token.py", line 5, in <module>
from . import schemas
ImportError: attempted relative import with no known parent package
Here is the main code
from . import models
from fastapi import FastAPI
from .database import engine
from .routers import books, users,authentication
app=FastAPI()
models.Base.metadata.create_all(engine)
app.include_router(books.router)
app.include_router(users.router)
app.include_router(authentication.router)
Here is my Code File Path If that helps solve the issue :
Code File Structure
I have tried everything but cant seem to find a way to fix this . I've redowloaded python. I've reinstalled every package, ive added paths to my packages, but nothing seems to work. Any help would be greatly appreciated. I am completely lost
Python doesn't know that the directory containing your modules (including main.py) is a package, therefore it can't properly locate imports. Create an empty __init__.py file in this directory to mark it as a regular package.
A rule of thumb is to mark all your directories that contain python modules as packages with this method.
There's another type of Python packages that may make your code sometimes work: namespace packages. They don't have to contain an __init__.py file. I recommend to just avoid them, unless you understand exactly what they're for and why you need them. [Doc reference]
For a quick reference, search through the FastAPI documentation for "project file structure" (it may be called something similar).

import ed25519._ed25519 works in powershell but not GAE

Does anyone have suggestions as to why I am getting the error below when using GAE and not with powershell? pip install comes back with requirement is already satisfied.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "C:\Users\kunle\Documents\LAGOS_BUSINESS\ISHOPEAZYV2\iShopEazyV2WebApp\ishopeazy.py", line 21, in <module>
from stellar_base.keypair import Keypair
File "C:\Users\kunle\Documents\LAGOS_BUSINESS\ISHOPEAZYV2\iShopEazyV2WebApp\lib\stellar_base\keypair.py", line 7, in <module>
from .utils import XdrLengthError, decode_check, encode_check
File "C:\Users\kunle\Documents\LAGOS_BUSINESS\ISHOPEAZYV2\iShopEazyV2WebApp\lib\stellar_base\utils.py", line 15, in <module>
import ed25519
File "C:\Users\kunle\Documents\LAGOS_BUSINESS\ISHOPEAZYV2\iShopEazyV2WebApp\lib\ed25519\__init__.py", line 1, in <module>
from .keys import (BadSignatureError, BadPrefixError,
File "C:\Users\kunle\Documents\LAGOS_BUSINESS\ISHOPEAZYV2\iShopEazyV2WebApp\lib\ed25519\keys.py", line 3, in <module>
from . import _ed25519
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\python\runtime\sandbox.py", line 1093, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named ed25519._ed25519
You cannot import C extension modules into a GAE application. ed25519._ed25519 is an extension module written in C.
You must find an implementation of Ed25519 that doesn't require the use of a C extension.

Numpy fails to import except in Admin command prompt

I recently updated numpy on Windows using pip and encountered a strange problem. After the update when I run python from an Admin prompt and import numpy, it works fine. But when I import it from a normal non-admin prompt, I get this error:
>>> import numpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\__init__.py", line 190, in <module>
from . import add_newdocs
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\__init__.py", line 9, in <module>
from .index_tricks import *
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\index_tricks.py", line 12, in <module>
from . import function_base
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\function_base.py", line 2489, in <module>
def corrcoef(x, y=None, rowvar=1, bias=np._NoValue, ddof=np._NoValue):
AttributeError: module 'numpy' has no attribute '_NoValue'
And when I tried again it changes to
>>> import numpy
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import numpy
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\__init__.py", line 190, in <module>
from . import add_newdocs
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\__init__.py", line 9, in <module>
from .index_tricks import *
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\index_tricks.py", line 6, in <module>
import numpy.core.numeric as _nx
AttributeError: module 'numpy' has no attribute 'core'
All the library files are in the file system although it sounds like it is unable to find numpy.core.
One possibly relevant fact is that python is installed in C:\Program Files (x86)\Python 3.5 rather than in the root directory. (This is the default install location as of 3.5, but has caused minor problems before.) I wonder if there could be a problem with file or directory permissions?
Also I tried reinstalling and even downgrading back to 1.10.4 (using the binary here and the problem persisted, although it wasn't there before the upgrade, and I installed it from the same source.
Any ideas on what the issue is?

Web programming Python powershell error

I'm new to python and I have just started web development. In the tutorial there is a page where I print out "hello world" using windows powershell. [But I have been keep getting this message and cannot access to local host :( please help me)
[error notice][1]
PS C:\Users\Administrator> python ‘C:\Program Files (x86)\Google\google_appengine\dev_appserver.py’ \Downloads\helloworld
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 83, in <module>
_run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 1040, in <module>
main()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 1033, in main
dev_server.start(options)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 758, in start
options.config_paths, options.app_id)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 831, in __init__
module_configuration = ModuleConfiguration(config_path, app_id)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 127, in __init__
self._config_path)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 423, in _parse_configuration
with open(configuration_path) as f:
IOError: [Errno 2] No such file or directory: '\\Downloads\\helloworld'
PS C:\Users\Administrator>
IOError: [Errno 2] No such file or directory: '\Downloads\helloworld'
1) \Downloads\helloworld folder exists?
2) are you using good path to folder?

QGIS python module is interfering with another python module installed at the system level

I am working with QGIS Pisa in Windows environment.I wanted to upgrade the scipy module of Python present inside OSGeo4W. For that I installed pip from the OSGeo4W windows command shell. I closed the command shell after installation and reopened it.
When I give the pip command inside OSFGeo4W windows command shell, it is referring to pip module installed at the system level and hence I am getting an error. I don't know how to correct this thing. Here is my error stack trace:
Traceback (most recent call last):
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name)
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\runpy.py", line 72, in _run_code exec code in run_globals
File "C:\Python27_32Bit\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\__init__.py", line 13, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\utils\__init__.py", line 26, in <module>
from pip._vendor import pkg_resources
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 76, in <module>
__import__('pip._vendor.packaging.specifiers')
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\packaging\specifiers.py", line 275, in <module>
class Specifier(_IndividualSpecifier):
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\packaging\specifiers.py", line 374, in Specifier
re.VERBOSE | re.IGNORECASE,
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\re.py", line 190, in compile return _compile(pattern, flags)
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\re.py", line 242, in _compile raise error, v # invalid expression
sre_constants.error: nothing to repeat
As you can see on the stacktrace, 3rd line from top, the code refers to pip module of python installed at the system level instead of pip module installed inside the QGIS Pisa. How can I correctly run this ?

Categories