Odoo 10 Configuration - python-3.x

I already setup the configurations in Odoo 10 but still facing with this error. I am using docker and eclipse. Any idea for this?
Traceback (most recent call last):
File "/home/user/Desktop/odoo-workspace/odoo10/odoo-bin", line 5, in <module>
__import__('pkg_resources').declare_namespace('odoo.addons')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2269, in declare_namespace
declare_namespace(parent)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2285, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2218, in _handle_ns
loader.load_module(packageName)
File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 962, in load_module
File "<frozen importlib._bootstrap_external>", line 787, in load_module
File "<frozen importlib._bootstrap>", line 262, in _load_module_shim
File "<frozen importlib._bootstrap>", line 604, in _exec
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/Desktop/odoo-workspace/odoo10/odoo/__init__.py", line 57, in <module>
import addons
ModuleNotFoundError: No module named 'addons'

Already solved. I changed the python interpreter to Python2.7 and installed pip.
To install pip for Python 2.7 install it from \https://bootstrap.pypa.io/pip/2.7/ :
curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
python -m pip install --upgrade "pip < 21.0"
after that I entered this command so that it will get all the requirements well:
pip install -r requirements.txt

Related

Error in function azure when updating runtime python - Failure Exception: AttributeError: module 'os' has no attribute 'add_dll_directory'

I've got an error when I try to update the python runtime of a function Azure, from 3.6 to 3.7 or 3.8, because version 3.6 is no longer used in Azure.
This is the full error:
Result: Failure Exception: AttributeError: module 'os' has no attribute 'add_dll_directory' Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 355, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/loader.py", line 127, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/site/wwwroot/CopyTransactionHttpTrigger/__init__.py", line 8, in <module> from confluent_kafka import avro File "/home/site/wwwroot/.python_packages/lib/site-packages/confluent_kafka/__init__.py", line 18, in <module> _delvewheel_init_patch_16682001180() File "/home/site/wwwroot/.python_packages/lib/site-packages/confluent_kafka/__init__.py", line 9, in _delvewheel_init_patch_16682001180 os.add_dll_directory(libs_dir)
Python 3.7 and 3.8
modules in requirements.txt file:
azure-functions==1.12.0 confluent-kafka==1.7.0 confluent-kafka[avro]==1.7.0 requests azure.storage.blob
I tried to update the function Azure with python 3.7 and 3.8 installing all dependencies above (modules) with such runtimes.
I think this module is necessary => module 'os' has no attribute 'add_dll_directory', and I don't know how to solve it.
What I see on the documentation of os module, it's used for windows. Do I need this module (os) in Azure?, can I avoid it by code?, if so, how?
I just install the function in linux on my local machine and deploy it from there adn it works. The issue was that I was deplying form a windows environtment.

ModuleNotFoundError: No module named 'onesignal_client'

I'm setting up my Django Rest API on Linux instance-template-1 5.10.0-14-cloud-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64
Python 3.9 is installed and Django 4x
I've installed One signal required by my API using
sudo pip3 install onesignal
sudo pip3 install onesignal_sdk
The module not found error throws up when I run
sudo python3.9 manage.py migrate
The detailed error trace is as follows :
File "/home/lineofsight/myprojects/my API/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/usr/local/lib/python3.9/dist-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.9/dist-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/usr/local/lib/python3.9/dist-packages/django/apps/config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/lineofsight/myprojects/My API/myapp_auth/models.py", line 25, in <module>
from myapp_notifications.helpers import get_notification_language_code_for_target_user
File "/home/lineofsight/myprojects/My API/myapp_notifications/helpers.py", line 4, in <module>
import onesignal as onesignal_sdk
File "/usr/local/lib/python3.9/dist-packages/onesignal/__init__.py", line 3, in <module>
from onesignal_client import OneSignal
ModuleNotFoundError: No module named 'onesignal_client'
I think you didn't install the correct python location.
Please try to install using the following commands.
python3.9 -m pip install onesignal
python3.9 -m pip install onesignal_sdk

pip broken, can't use most of pip commands (on windows)

So I was working with python, coding and installing packages, everything was going ok, but then everything with pip stoped working, and every times the cmd prompt me :
Traceback (most recent call last):
File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Python39\Scripts\pip.exe\__main__.py", line 7, in <module>
File "c:\python39\lib\site-packages\pip\_internal\cli\main.py", line 69, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "c:\python39\lib\site-packages\pip\_internal\commands\__init__.py", line 91, in create_command
module = importlib.import_module(module_path)
File "c:\python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 855, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "c:\python39\lib\site-packages\pip\_internal\commands\list.py", line 9, in <module>
from pip._internal.cli.req_command import IndexGroupCommand
File "c:\python39\lib\site-packages\pip\_internal\cli\req_command.py", line 20, in <module>
from pip._internal.index.collector import LinkCollector
File "c:\python39\lib\site-packages\pip\_internal\index\collector.py", line 5, in <module>
import cgi
File "c:\python39\lib\cgi.py", line 41, in <module>
import html
ModuleNotFoundError: No module named 'html'
I never run into those kind of errors.
BTW pip -V is working, and when I try to run a programme using python with the already installed package and it still works fine.
I tried to reinstall python partially after restarting my pc, and nothing with pip has changed
I fixed it, here is what I have done, and more context that may help you understand where the problem was coming from :
So I was doing an gui app using pyqt5 and I was having trouble with PySide2, the first error of this kind was when I tried to install it with pip (pip install PySide2). I don't know where the error came from, but if you encounter this after in a similar situation, there way be a problem with that.
what I have done to fix it was not re-installing python or pip but using the repair "tool" when installing the version of python already installed.

Upgrading Python version for running and creating custom container for Sagemaker Endpoint

[UPDATED] We are currently working on creating a Multi-Arm Bandit model for sign up optimization using the Build Your Own workflow that can be found here (basically substituting the model for our own):
https://github.com/aws/amazon-sagemaker-examples/tree/master/advanced_functionality/scikit_bring_your_own
Our project directory is set up as:
Project Directory
The issue is that I added some code including the dataclasses library that is only available since Python 3.7, and our project seems to keep using 3.6, causing a failure when running the Cloud Formation set up. The error in our Cloudwatch Logs is:
2021-03-31T11:04:11.077-05:00 Copy
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.6/dist-packages/gunicorn/util.py", line 359, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/opt/program/wsgi.py", line 1, in <module>
import predictor as myapp
File "/opt/program/predictor.py", line 9, in <module>
from model_contents.model import MultiArmBandit, BanditParameters
File "/opt/program/model_contents/model.py", line 7, in <module>
from dataclasses import dataclass, field, asdict
Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/gunicorn/arbiter.py", line 589, in spawn_worker worker.init_process() File "/usr/local/lib/python3.6/dist-packages/gunicorn/workers/base.py", line 134, in init_process self.load_wsgi() File "/usr/local/lib/python3.6/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load return self.load_wsgiapp() File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/local/lib/python3.6/dist-packages/gunicorn/util.py", line 359, in import_app mod = importlib.import_module(module) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/opt/program/wsgi.py", line 1, in <module> import predictor as myapp File "/opt/program/predictor.py", line 9, in <module> from model_contents.model import MultiArmBandit, BanditParameters File "/opt/program/model_contents/model.py", line 7, in <module> from dataclasses import dataclass, field, asdict
2021-03-31T11:04:11.077-05:00
Copy
ModuleNotFoundError: No module named 'dataclasses'
ModuleNotFoundError: No module named 'dataclasses'
Our updated Dockerfile is:
# This is a Python 3 image that uses the nginx, gunicorn, flask stack
# for serving inferences in a stable way.
FROM ubuntu:18.04
# Retrieves information about what packages can be installed
RUN apt-get -y update && apt-get install -y --no-install-recommends \
wget \
python3-pip \
python3.8 \
python3-setuptools \
nginx \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Set python 3.8 as default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
# Here we get all python packages.
RUN pip --no-cache-dir install numpy boto3 flask gunicorn
# Set some environment variables. PYTHONUNBUFFERED keeps Python from buffering our standard
# model_output stream, which means that logs can be delivered to the user quickly. PYTHONDONTWRITEBYTECODE
# keeps Python from writing the .pyc files which are unnecessary in this case. We also update
# PATH so that the train and serve programs are found when the container is invoked.
ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
ENV PATH="/opt/program:${PATH}"
ENV PYTHONPATH /model_contents
# Set up the program in the image
COPY bandit/ /opt/program/
WORKDIR /opt/program/
RUN chmod +x /opt/program/serve && chmod +x /opt/program/train
LABEL git_tag=$GIT_TAG
I'm not sure if the nginx.conf file defaults to Py 3.6 so I want to make sure that it's not a big hassle to upgrade to Py 3.7 or 3.8 without many changes.
You can update the Dockerfile after it install Python3.8 using apt-get with the following RUN commands
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
The first RUN command will link /usr/bin/python to /usr/bin/python3.8 and the second one will link /usr/bin/python3 to /usr/bin/python3.8

Errors when running python3 manage.py syncdb to sync databases in my django application

Hi I am pretty new to django and I ended up with a very big error when I tried running the command python3 manage.py syncdb. I am trying to create a form builder application and encountered the error when I was trying to sync the database with the project. I am using the django-forms-builder from pypi.org.
For the error:
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/apps/config.py", line 94, in create
module = import_module(entry)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'foo'
Any kind of help will be appreciated.
You must have forgotten to install a dependency that is listed in your INSTALLED_APPS. Try pip install foo. Or you can remove foo from the installed apps.

Resources