problem with psycopg2

Please post any questions about developing your plugin here. Please use the search function before posting!
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

problem with psycopg2

Postby qwexvf » Tue Apr 04, 2017 5:05 pm

has anyone ever tried to work with peewee + psycopg?

Source Code

Syntax: Select all

from playhouse.postgres_ext import PostgresqlExtDatabase
psql_db = PostgresqlExtDatabase('csgo', user='csgo', password='csgo')


Error code

Syntax: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
plugin = self.manager.load(plugin_name)
File "../addons/source-python/packages/source-python/plugins/manager.py", line 193, in load
plugin._load()
File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
self.module = import_module(self.import_name)
File "../addons/source-python/plugins/lo3/lo3.py", line 9, in <module>
from playhouse.postgres_ext import PostgresqlExtDatabase
File "../addons/source-python/packages/site-packages/playhouse/postgres_ext.py", line 26, in <module>
from psycopg2.extensions import adapt
File "../addons/source-python/packages/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa

ImportError: No module named 'psycopg2._psycopg'


This is too strange.
Anyone please help me.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: problem with psycopg2

Postby Ayuto » Tue Apr 04, 2017 6:38 pm

Looks like you are missing the _psycopg module.
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

Re: problem with psycopg2

Postby qwexvf » Tue Apr 04, 2017 6:42 pm

Ayuto wrote:Looks like you are missing the _psycopg module.


Thats what i thought so to make it clear.
thats what i did

Code: Select all

pip install psycopg2
cp -a /home/vagrant/.pyenv/versions/3.6/lib/python3.6/site-packages/psycopg2 /home/csgo/csgo-test/csgo/addons/source-python/packages/site-packages/.


anything i'm missing ?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: problem with psycopg2

Postby Ayuto » Tue Apr 04, 2017 6:45 pm

Have you checked if that file exists? If it exists, the reason could be that Source.Python is using 3.5 and not 3.6.
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

Re: problem with psycopg2

Postby qwexvf » Tue Apr 04, 2017 6:51 pm

Ayuto wrote:Have you checked if that file exists? If it exists, the reason could be that Source.Python is using 3.5 and not 3.6.


Sorry, i tried 3.5 ~ 3.6 but same ...
can you try out?

Oh and if i do that in python itrepter it works as i want.


Screenshot
Image

This is what it looks inside of psycopg2
Image
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: problem with psycopg2

Postby Ayuto » Tue Apr 04, 2017 7:28 pm

Did you try it with the 32 Bit version of Python 3.5?

Edit: Yes, according to the screenshot you installed it using the 64 Bit version. You will need the 32 Bit version.
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

Re: problem with psycopg2

Postby qwexvf » Tue Apr 04, 2017 7:32 pm

Ayuto wrote:Did you try it with the 32 Bit version of Python 3.5?


Wait... 32bit?... Oook. let me compile it real quick....
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

Re: problem with psycopg2

Postby qwexvf » Tue Apr 04, 2017 7:51 pm

Ayuto wrote:Did you try it with the 32 Bit version of Python 3.5?

Edit: Yes, according to the screenshot you installed it using the 64 Bit version. You will need the 32 Bit version.


Thanks mate. everything worked.

it took a bit to figure out that i needed 32bit version >< but hopefully i can connect my sweet database now
thanks for your support <3

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 30 guests