asdf-community / asdf-python

Python plugin for the asdf version manager
https://github.com/asdf-vm/asdf
MIT License
656 stars 56 forks source link

module issue #60

Closed vasiliyb closed 4 years ago

vasiliyb commented 5 years ago

For some reason, even after a module is installed (pygresql) via pip, its failing to load:

import csv
import pygresql
% python test.py
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    import pygresql
% which python
/Users/xxx/.asdf/shims/python
% pip install pygresql
Requirement already satisfied: pygresql in /Users/xx/.asdf/installs/python/3.7.3/lib/python3.7/site-packages (5.1)
iamareebjamal commented 4 years ago

Yep. Even virtualenv isn't working correctly. It is trying to load things from system libraries

danhper commented 4 years ago

This has nothing to do with asdf, the package pygresql simply does not export a module called pygresql (which is unfortunate, but Python packaging system allows this). From the documentation, it seems that you need to import the pg module:

http://www.pygresql.org/contents/tutorial.html

danhper commented 4 years ago

BTW, if you run into this kind of issue, you can use

pip show -f PACKAGE_NAME

which will show you a list of files installed by the package. Hopefully, there should be a PACKAGE_NAME/__init__.py but sometimes, as for pygresql, it is not the case.