Integrate Odoo11 with Pycharm to debug on windows 10 - python

I want to debug with Pycharm on windows 10. So I reference the youtube video.
How to debug Odoo using Pycharm in Window 10
https://www.youtube.com/watch?v=aCXlh4Z2mbQ
I copy the server directory form odoo 11 installed directory. And then use Pycharm to open.
I also install Package reuirements and Visual C++ 14.0(in odoo 11 vcredist directory).
I install win-psycopg for python 3.5, because it does not support Python 3.6.1.
My Pycharm configuration setting as below:
Script path = odoo-bin
Parameters = -w openpg -r openpgpwd --addons-path=addons
Working directory = D:\tmp\server
When I run the project , Pycharm displays error messages as below:
Does somebody know how to solve it?
D:\Python36\python.exe odoo-bin -w openpg -r openpgpwd --addons-path=addons
Traceback (most recent call last):
File "odoo-bin", line 5, in
import odoo
File "D:\tmp\server\odoo__init__.py", line 84, in
from . import modules
File "D:\tmp\server\odoo\modules__init__.py", line 8, in
from . import db, graph, loading, migration, module, registry
File "D:\tmp\server\odoo\modules\graph.py", line 10, in
import odoo.tools as tools
File "D:\tmp\server\odoo\tools__init__.py", line 10, in
from .convert import *
File "D:\tmp\server\odoo\tools\convert.py", line 22, in
from .yaml_import import convert_yaml_import
File "D:\tmp\server\odoo\tools\yaml_import.py", line 23, in
from .safe_eval import safe_eval
File "D:\tmp\server\odoo\tools\safe_eval.py", line 21, in
from psycopg2 import OperationalError
File "D:\Python36\lib\site-packages\psycopg2-2.6.2-py3.6-win-amd64.egg\psycopg2__init__.py", line 50, in
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ModuleNotFoundError: No module named 'psycopg2._psycopg'
Process finished with exit code 1

The error:
ModuleNotFoundError: No module named 'psycopg2._psycopg'
it's because you lose dependencies for odoo server, in this case psycopg2 just excecute:
pip install psycopg2-binary
I hope this answer can be helpfull for you or anyone else.

Related

Script works in Anaconda Prompt but not via Command Line

I am unable to run a python script in the command line, and this script works great in Jupyter Notebook and via Anaconda Prompt. This appears to be an issue importing the ssl module during initialization of another module I am importing (mygeotab).
I have googled the error and done as much as I can to diagnose the most common cause which appears to be PATH issues.
I have already diagnosed the PATH to a point, and have added the location of the /lib/ and python.exe to the environment variables. Also, during testing I began my script with the below to protect myself from path issues and printed the path before and after the 'append', which did not have an impact on the problem.
import sys
print(sys.path)
sys.path.append('C:\\Users\\xxxxxx\\Python Scripts')
sys.path.append('C:\\Anaconda3\\python37.zip')
sys.path.append('C:\\Anaconda3\\DLLs')
sys.path.append('C:\\Anaconda3\\lib')
sys.path.append('C:\\Anaconda3')
sys.path.append('C:\\Anaconda3\\lib\\site-packages')
sys.path.append('C:\\Anaconda3\\lib\\site-packages\\win32')
sys.path.append('C:\\Anaconda3\\lib\\site-packages\\win32\\lib')
sys.path.append('C:\\Anaconda3\\lib\\site-packages\\Pythonwin')
sys.path.append('C:\\Anaconda3\\lib\\site-packages\\IPython\\extensions')
sys.path.append('C:\\Users\\xxxxxx\\.ipython')
sys.path.append('C:\\Anaconda3\\Lib')
sys.path.append('C:\\Anaconda3\\Lib\\site-packages')
print(sys.path)
import mygeotab
import pandas as pd
import pyodbc as py
from mygeotab.ext import feed
import sqlalchemy
from time import sleep
However, when I attempt to run the script via the standard command line, I get the below error:
Traceback (most recent call last):
File "PYTHON_GEOTAB_TRIP_FEED.py", line 33, in <module>
import mygeotab
File "C:\Anaconda3\lib\site-packages\mygeotab\__init__.py", line 9, in <module>
from .api import Credentials
File "C:\Anaconda3\lib\site-packages\mygeotab\api.py", line 14, in <module>
import ssl
File "C:\Anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
The mygeotab module and ssl.py are both in the locations designated in the Traceback. '_ssl' is the only reference I can not seem to diagnose. Again, this works fine in both Notebook and Anaconda Prompt.
Any ideas?
Windows Server 2008 R2
Anaconda 2019.07 x64
Python 3.7.3 x64
This was solved for me by installing a separate instance of Python 3.7, moving the PATH references and other pointers. I installed pip, mygeotab, and the other packages into the native Python 3.7 instance. It just appears you can't use the one baked into anaconda the way I thought. Thanks for the help everyone.

"ImportError: No module named pkg_resources" when importing google.cloud.datastore

I am attempting to use the Google Cloud Datastore, but importing google.cloud.datastore gives an ImportError:
ERROR 2018-03-13 19:28:29,013 wsgi.py:263]
Traceback (most recent call last):
File "/home/<user>/Software/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/<user>/Software/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/<user>/Software/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/<user>/Projects/<my_project>/main.py", line 1, in <module>
from my_project import app
File "/home/<user>/Projects/<my_project>/<my_project>/__init__.py", line 2, in <module>
from my_project.submit.controllers import submit
File "/home/<user>/Projects/<my_project>/<my_project>/submit/controllers.py", line 6, in <module>
from . import model_datastore
File "/home/<user>/Projects/<my_project>/<my_project>/submit/model_datastore.py", line 2, in <module>
from google.cloud import datastore
File "/home/<user>/Projects/<my_project>/env/local/lib/python2.7/site-packages/google/cloud/datastore/__init__.py", line 57, in <module>
from pkg_resources import get_distribution
ImportError: No module named pkg_resources
I am on Linux Mint attempting to run a Google App Engine local dev server.
I am using a virtual environment. Both setuptools and pkg_resources are installed and updated in the virtual environment. When I enter the python cmd line interpreter from the virtual env and import pkg_resources, it works fine. When I run the google app engine dev server by doing dev_appserver app.yaml, everything works fine until I access the page that activates the handler that imports datastore, then I get this error.
None of the other similar posts about 'pkg_resources` import error were helpful.
If there is any other info I can provide that would help, please let me know. Thanks!
In the standard environment you need to install all your dependencies inside your application. See Using third-party libraries.
Whatever you have installed in the local environment (virtual or not) doesn't matter, GAE doesn't know how to use those and your app might not work properly locally and definitely won't work when deployed on GAE.
You traceback indicates that you're loading the datastore library from your virtual env, not from your app, which is most likely why it doesn't work:
.../env/local/lib/python2.7/site-packages/google/cloud/datastore/__init__.py
You need to fix your app dependency installation.
This discussion might be of interest as well: No module named warnings when starting GAE inside virtualenv locally

Import error on first-party library with dev_appserver.py

On Ubuntu 16.04, am suddenly getting import errors from the local GAE development server.
The local dev server starts up, including the admin interface, but app no longer loads.
Native python imports of the same library on same machine (in this case "from google.cloud import datastore") work fine.
The GAE standard app does run when deployed, but development just got a little challenging.
google-cloud is version 0.27.0
gcloud components is 172.0.1
python is Anaconda 2.7.13
GAE is standard
I have confirmed to the best of my middling abilities that $PATH is correct for all named libraries.
I have removed and re-added all the named libraries to no effect.
cachetools(2.0.1) it should probably be noted, is installed as a dependency of the google cloud libraries, so I don't think this is addressable through requirements.txt or "libraries" in app.yaml.
I did recently go through a cycle of removing and adding libraries to fix a problem with apache_beam 2.0.1, so I may have jacked up something else, but am not sure where to look.
Suggestions deeply appreciated. Full traceback (from admin, same as from app):
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/request_handler.py", line 232, in handle_interactive_request
exec(compiled_code, self._command_globals)
File "<string>", line 1, in <module>
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/cloud/datastore/__init__.py", line 61, in <module>
from google.cloud.datastore.client import Client
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/cloud/datastore/client.py", line 23, in <module>
from google.cloud.client import ClientWithProject
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/cloud/client.py", line 27, in <module>
from google.oauth2 import service_account
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/oauth2/service_account.py", line 79, in <module>
from google.auth import jwt
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/auth/jwt.py", line 49, in <module>
import cachetools
ImportError: No module named cachetools
The stacktrace indicates you're running the libraries from the local system installation (the site-packages dir), not from your app.
For standard env GAE apps you need to install the dependencies inside your app and they will be uploaded to GAE together with your app code.
More specifically you need to use the -t <your_app_lib_dir> option for the pip installation. From Installing a third-party library:
Use pip (version 6 or later) with the -t <directory> flag to copy the libraries into the folder you created in the previous
step. For example:
pip install -t lib/ <library_name>
I addressed my problem through the requirements.txt file in app root directory.
I had: google-cloud==0.22.0
and changed it to: google-cloud==0.27.0
which fixed it.

Import error when using uwsgi with django (Symbol not found: __PyInt_AsInt)

I've tried looking for a fix, but wasn't able to. Sorry if this question exists elsewhere.
I'm following http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html, and am currently trying to make sure django works with uWSGI. I'm trying to run uWSGI --http-socket :8000 --module mysite.wsgi, but am getting:
Traceback (most recent call last):
File "./mysite/wsgi.py", line 13, in <module>
from django.core.wsgi import get_wsgi_application
File "/anaconda/lib/python2.7/site-packages/django/core/wsgi.py", line 2, in <module>
from django.core.handlers.wsgi import WSGIHandler
File "/anaconda/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 3, in <module>
import cgi
File "/anaconda/lib/python2.7/cgi.py", line 50, in <module>
import mimetools
File "/anaconda/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/anaconda/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/anaconda/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyInt_AsInt
Referenced from: /anaconda/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
I already had issues with uWSGI not using the right installation.uwsgi would try to use /usr/local/bin/uwsgi despite
which uwsgi
//anaconda/bin/uwsgi
, resulting in No such file or directory. Currently, I set uWSGI="//anaconda/bin/uwsgi" to get around the problem at and get uwsgi to work, but I suspect a similar problem may be occurring. I think it might be trying to use /usr/bin/python instead of /anaconda/bin/python, and it can't import from anaconda, resulting in the error. However, I'm not sure how to fix it/confirm that this is the problem, and any advice would be appreciated.
Thanks!
EDIT: I have also tried import _io using all of the current versions of python installed, and there was no problem. brew unlink python helped deal with the conflicting anaconda version for the uwsgi problem (initially fixed with alias, as above), but this issue still exists.
EDIT: Removing anaconda from $PATH, and then reinstalling/unlinking/linking django, openssl, and libxml2 "works". I'll find out if this causes problems in the later steps shortly, but I still have no idea what was happening with the anaconda install. I'd really like to figure out what's going on since I use scipy/numpy/etc. very frequently, so this is definitely a temporary fix. Any ideas?
I just encountered this issue trying to run uwsgi on my mac with my django project
uwsgi --http :9090 --module uwsgi_django_project.wsgi
(in this case my django project was named uwsgi_django_project)
The stack-trace from uwsgi was
Traceback (most recent call last):
File "./uwsgi_django_project/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
File "/opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/site-packages/django/utils/version.py", line 1, in <module>
import datetime
File "/opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/datetime.py", line 8, in <module>
import math as _math
ImportError: dlopen(/opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/lib-dynload/math.cpython-38-darwin.so, 2): Symbol not found: _PyExc_MemoryError
Referenced from: /opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/lib-dynload/math.cpython-38-darwin.so
Expected in: flat namespace
in /opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/lib-dynload/math.cpython-38-darwin.so
unable to load app 0 (mountpoint='') (callable not found or import error)
Very similar to the error OP was getting except Symbol not found: _PyExc_MemoryError instead.
I had installed uwsgi via pip inside my conda environment and apparently there is an incompatability between the package installed via pip and the anaconda environment's python.
The solution was to remove uwsgi from my environment
pip uninstall uwsgi
and install it using anaconda
conda install -c conda-forge uwsgi
after doing this and running uwsgi with my django app it worked fine.
Credit to this blog where I found the solution to my issue which probably would solve a lot of similar issues with uwsgi and django

Python error: No module named RuntimeError

Im trying to figured out this problem. Yesterday I installed PyScripter and since then, scripts doesnt work. When I run any script (in PyScripter or IDLE) and trying to "import arcpy", it gets this error:
import arcpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import arcpy
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
from geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
File "C:\Python26\ArcGIS10.0\lib\arcgisscripting.py", line 81, in <module>
from RuntimeError import RuntimeError
ImportError: No module named RuntimeError
Have somebody any suggestion how to fix it?
Thanks to all very much!
Sounds like the module is not installed properly (or at all). To verify, do the following:
open a shell and start the python shell by typing python
(If this doesn't display an error, check that python is added to your system path or if it is even installed at all. But if you've used Python on said machine maybe system path issue)
enter the commmand help('modules')
review the list of modules that's returned to see whether arcpy is included
if not, then you may have to reinstall the module

Categories