Python Forum

Full Version: A hidden library?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I'm new here because I need to help a friend of mine who runs Python on a Linux platform. To install a Python library on that platform, he ran pip and he knows that the library lives on his hard disk. But the computer can't find that library. Do you think there's a typo in a path name that should point to that library? What else could cause my friend's trouble? He says that he hasn't edited his bash profile. Thanks.
He has to check if pip is really installing modules for the python interpreter that he is running his scripts.

He can investigate it with:
1 - Check pip version and its bond python interpreter.
$ pip -V

2 - Then check if the module was really installed.
$ pip list

3 - Modules that have - in their names must be imported with _.
Example:
$ pip install my-module
And when importing:
import my_module
sys.path will show you where your python directories are located, and such your 3rd party libs you install. In my case it resides in usr/local/lib/python3.6/site-packages for python3.6 version

metulburr@ubuntu:~$ python3.6
Python 3.6.1 (default, Jun  8 2017, 06:36:16) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages']
>>> import os
>>> os.listdir('/usr/local/lib/python3.6/site-packages')
['lxml-4.1.1.dist-info', 'jwt', 'txaio-2.8.2.dist-info', 'qtconsole-4.3.1.dist-info', 'jupyter_core', 'socks.py', 'virtualenv_support', 'ipykernel', 'direct', 'zmq', 'pygame', 'PySocks-1.6.8-py3.6.egg-info', 'panda3d_tools', 'tornado', 'jupyter-1.0.0.dist-info', 'pygments', 'ipykernel_launcher.py', 'schedule', 'ipython_genutils', 'mutagen', 'urwid-2.0.1-py3.6.egg-info', 'PyVirtualDisplay-0.2.1-py3.6.egg-info', 'jedi', 'fake_useragent', 'pytz-2017.2.dist-info', 'nbconvert', 'jupyter_console', 'PyQt5', 'pubsub', 'idna-2.6.dist-info', 'virtualenv.py', 'vpnotebook', 'simplegeneric-0.8.1-py3.6.egg-info', 'ipython-6.2.1.dist-info', 'twilio-6.18.0.dist-info', 'wcwidth-0.1.7.dist-info', 'jupyter_client', 'certifi', 'jupyter.py', 'easy_install.py', 'ptyprocess', 'decorator.py', 'txaio', 'mutagen-1.40.0-py3.6.egg-info', 'selenium', 'PyLyrics-1.1.0-py3.6.egg-info', 'panda3d', 'EasyProcess-0.2.3-py3.6.egg-info', 'idna', 'docopt.py', 'setuptools-28.8.0.dist-info', 'youtube_dl', 'widgetsnbextension', 'pandocfilters.py', 'mistune', 'pexpect', 'twilio', 'pexpect-4.2.1.dist-info', 'Jinja2-2.9.6.dist-info', 'PyQt5-5.10.1.dist-info', 'pickleshare.py', 'html5lib-1.0b10.dist-info', 'urllib3', 'jsonschema', 'bs4', 'prompt_toolkit-1.0.15.dist-info', 'wx', 'testpath-0.3.1.dist-info', 'setuptools', 'qtconsole', 'bleach', 'chardet-3.0.4.dist-info', 'urwid', 'selenium-3.5.0.dist-info', 'python_dateutil-2.6.0.dist-info', 'PyLyrics', '__pycache__', 'PIL', 'simplegeneric.py', 'ipython_genutils-0.2.0.dist-info', 'numpy', 'autobahn', 'vpnotebook-0.1.3-py3.6.egg-info', 'beautifulsoup4-4.6.0.dist-info', 'terminado', 'Pillow-5.4.1.dist-info', 'decorator-4.1.2.dist-info', 'pip', 'fake_useragent-0.1.7-py3.6.egg-info', 'requests-2.18.4.dist-info', 'certifi-2017.7.27.1.dist-info', 'PySimpleGUI-2.7.0.dist-info', 'pkg_resources', 'vpython-7.1.3-py3.6.egg-info', 'jupyter_core-4.3.0.dist-info', 'markupsafe', 'widgetsnbextension-3.0.3.dist-info', 'wxPython-4.0.3.dist-info', 'PySimpleGUI', 'lxml', 'sockshandler.py', 'terminado-0.6-py3.6.egg-info', 'six-1.11.0.dist-info', 'Pygments-2.2.0.dist-info', 'notebook', 'traitlets', 'ipykernel-4.6.1.dist-info', 'chardet', 'nbformat', 'ptpython-0.41.dist-info', 'jupyter_console-5.2.0.dist-info', 'html5lib', 'ipywidgets-7.0.1.dist-info', 'sip-4.19.8.dist-info', 'wcwidth', 'IPython', 'bleach-2.1.dist-info', 'dateutil', 'webencodings', 'urllib3-1.22.dist-info', 'bs4-0.0.1-py3.6.egg-info', 'pygame-1.9.3.dist-info', 'entrypoints-0.2.3.dist-info', 'parso', 'entrypoints.py', 'tornado-4.5.2-py3.6.egg-info', 'twisted', 'pip-9.0.1.dist-info', 'panda3d-1.10.0.dev1654.dist-info', 'virtualenv-15.1.0.dist-info', 'pytz', 'jsonschema-2.6.0.dist-info', 'pandac', 'six.py', 'notebook-5.1.0.dist-info', 'jupyter_client-5.1.0.dist-info', 'README.txt', 'traitlets-4.3.2.dist-info', 'pandocfilters-1.4.2-py3.6.egg-info', 'easyprocess', 'jinja2', 'testpath', 'mistune-0.7.4.dist-info', 'Pypubsub-4.0.0.dist-info', 'pandas-0.20.2.dist-info', 'nbconvert-5.3.1.dist-info', 'nbformat-4.4.0.dist-info', 'parso-0.1.0.dist-info', 'PyJWT-1.6.4.dist-info', 'ptpython', 'docopt-0.6.2-py3.6.egg-info', 'sip.so', 'jedi-0.11.0.dist-info', 'ipywidgets', 'ptyprocess-0.5.2.dist-info', 'pandas', 'mistune.py', 'requests', 'youtube_dl-2018.12.9.dist-info', 'pickleshare-0.7.4.dist-info', 'MarkupSafe-1.0-py3.6.egg-info', 'pyzmq-16.0.2.dist-info', 'webencodings-0.5.1.dist-info', 'vpython', 'autobahn-17.9.3.dist-info', 'numpy-1.13.0.dist-info', 'schedule-0.5.0.dist-info', 'pyvirtualdisplay', 'prompt_toolkit']
Thank you, folks.