Обсуждение: [psycopg] Import issue after PIP install

Поиск
Список
Период
Сортировка

[psycopg] Import issue after PIP install

От
Mike Rice
Дата:
I'm currently trying to test out using psycopg2 and did a PIP install on my windows machine.  The problem is that as soon as I import the module I get the following error thrown back:

--------------------------------------------------------------------------------------------------------------------------------------
  File "\\192.168.88.142\Mike\development\python\postgresql_connect_test.py", line 3, in <module>
    import psycopg2
  File "C:\Python 3.6\lib\site-packages\psycopg2\__init__.py", line 50, in <module>
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: can't import datetime module
--------------------------------------------------------------------------------------------------------------------------------------

I'm still in the process of learning Python, and my Google-Fu has failed me in finding out what's going on here.  Any help would be appreciated.

--
- Mike

Re: [psycopg] Import issue after PIP install

От
Adrian Klaver
Дата:
On 06/06/2017 07:22 AM, Mike Rice wrote:
> I'm currently trying to test out using psycopg2 and did a PIP install on
> my windows machine.  The problem is that as soon as I import the module
> I get the following error thrown back:
>
>
--------------------------------------------------------------------------------------------------------------------------------------
>    File
> "\\192.168.88.142\Mike\development\python\postgresql_connect_test.py",
> line 3, in <module>
>      import psycopg2
>    File "C:\Python 3.6\lib\site-packages\psycopg2\__init__.py", line 50,
> in <module>
>      from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
> ImportError: can't import datetime module
>
--------------------------------------------------------------------------------------------------------------------------------------
>
> I'm still in the process of learning Python, and my Google-Fu has failed
> me in finding out what's going on here.  Any help would be appreciated.

The datetime  module is part of the standard library for Python so it
should be there. I suspect some install/PATH issue with the Python
install itself. So:

1) How did you install Python on Windows?

2) Where is \\192.168.88.142?

>
> --
> - Mike


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [psycopg] Import issue after PIP install

От
Mike Rice
Дата:
I forgot to reply all, sorry about that.

To install Python I used the python installer and allowed it to configure the PATH environment variables.  Below is the PATH configuration.

Inline image 1

I also have PYTHONPATH set to:

Inline image 2

C:\Python is my Python 3.5 installation.  

192.168.88.142 is my local NAS where I store all my scripting.  I tested moving it over to the local drive and it seemed to do the trick, so I'll have to dig a little deeper to find out how to configure things so that I can run my scripts off of my NAS.  I' haven't run into any issues with it previously which is why I was confused.

Thanks for the quick response!

On Tue, Jun 6, 2017 at 10:29 AM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 06/06/2017 07:22 AM, Mike Rice wrote:
I'm currently trying to test out using psycopg2 and did a PIP install on my windows machine.  The problem is that as soon as I import the module I get the following error thrown back:

--------------------------------------------------------------------------------------------------------------------------------------
   File "\\192.168.88.142\Mike\development\python\postgresql_connect_test.py", line 3, in <module>
     import psycopg2
   File "C:\Python 3.6\lib\site-packages\psycopg2\__init__.py", line 50, in <module>
     from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: can't import datetime module
--------------------------------------------------------------------------------------------------------------------------------------

I'm still in the process of learning Python, and my Google-Fu has failed me in finding out what's going on here.  Any help would be appreciated.

The datetime  module is part of the standard library for Python so it should be there. I suspect some install/PATH issue with the Python install itself. So:

1) How did you install Python on Windows?

2) Where is \\192.168.88.142?


--
- Mike


--
Adrian Klaver
adrian.klaver@aklaver.com



--
- Mike
Вложения

Re: [psycopg] Import issue after PIP install

От
Adrian Klaver
Дата:
On 06/06/2017 09:36 AM, Mike Rice wrote:
> I forgot to reply all, sorry about that.

Yeah, I was just replying to that when this post came through.

>
> To install Python I used the python installer and allowed it to
> configure the PATH environment variables.  Below is the PATH configuration.
>
> Inline image 1
>
> I also have PYTHONPATH set to:
>
> Inline image 2
>
> C:\Python is my Python 3.5 installation.
>
> 192.168.88.142 is my local NAS where I store all my scripting.  I tested
> moving it over to the local drive and it seemed to do the trick, so I'll
> have to dig a little deeper to find out how to configure things so that
> I can run my scripts off of my NAS.  I' haven't run into any issues with
> it previously which is why I was confused.

By previously do you mean using the initial Python 3.5 install?

I would try in a terminal:

python -V

to see what shows up.

And in your script:

import sys

print(sys.version)

to see what it is picking up.


>
> Thanks for the quick response!
>



--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [psycopg] Import issue after PIP install

От
Mike Rice
Дата:
I've got two separate installs/folders for each python environment, one for 3.6 and one for 3.5.  The errors I gave above are from my 3.6 IDLE session.

In C:\Python folder I get version 3.5.3
In C:\Python 3.6 I get version 3.6.1

Inside of IDLE 3.6 when I print sys.version I'm getting 3.6.1.

The issue probably stems from the location of my scripts, as when I run my test script from c:\Python 3.6\Test I'm not seeing the error show up.  So it's probably just me being a Python newb and not building things correctly :)  

Thanks,
Mike

On Tue, Jun 6, 2017 at 12:42 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 06/06/2017 09:36 AM, Mike Rice wrote:
I forgot to reply all, sorry about that.

Yeah, I was just replying to that when this post came through.


To install Python I used the python installer and allowed it to configure the PATH environment variables.  Below is the PATH configuration.

Inline image 1

I also have PYTHONPATH set to:

Inline image 2

C:\Python is my Python 3.5 installation.

192.168.88.142 is my local NAS where I store all my scripting.  I tested moving it over to the local drive and it seemed to do the trick, so I'll have to dig a little deeper to find out how to configure things so that I can run my scripts off of my NAS.  I' haven't run into any issues with it previously which is why I was confused.

By previously do you mean using the initial Python 3.5 install?

I would try in a terminal:

python -V

to see what shows up.

And in your script:

import sys

print(sys.version)

to see what it is picking up.




Thanks for the quick response!




--
Adrian Klaver
adrian.klaver@aklaver.com



--
- Mike