0

I am confused on python on its installation path and configuration.

I know pip this command for installation or listing the modules.

The example is like pip freeze. It will show up the list of module.

Recently, I got an error when I execute pip. I had python2 and python3 on the system without any virtualenv. I use ls /usr/bin/python* -al | awk {print $9 $10 $11} to know python commands and ls /usr/bin/pip* -al to know the pip commands.

python->python2.7
python2->python2.7
python2.7
python2.7-config->arm-linux-gnueabihf-python2.7-config
python2-config->python2.7-config
python3->python3.4
python3.4
python3.4m
python3m->python3.4m
python-config->python2.7-config

pip pip2 pip3

In addition, I use ls on /usr/local/bin and know the pip commands.

pip pip2 pip2.7 pip3 pip3.4 pip3.5

The error message is this when I execute pip.

Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 11, in <module>
    load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 572, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2752, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2405, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2411, in resolve
     module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 76, in <module>
    from pip.commands import commands, get_summaries, get_similar_commands
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/__init__.py", line 6, in <module>
    from pip.commands.bundle import BundleCommand
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/bundle.py", line 6, in <module>
    from pip.commands.install import InstallCommand
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 5, in <module>
    from pip.req import InstallRequirement, RequirementSet, parse_requirements
  File "/usr/local/lib/python2.7/dist-packages/pip/req/__init__.py", line 3, in <module>
    from .req_install import InstallRequirement
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 42, in <module>
    from pip.utils.hashes import Hashes
  File "/usr/local/lib/python2.7/dist-packages/pip/utils/hashes.py", line 5, in <module>
    from pip.exceptions import HashMismatch, HashMissing, InstallationError
ImportError: cannot import name HashMissing`

How to resolve this error? Why does the system show up the error?

jefferyear
  • 117
  • 7
  • Possible duplicate of [Keras import error Nadam](https://stackoverflow.com/questions/38809686/keras-import-error-nadam) – ivan_pozdeev Mar 16 '18 at 02:51
  • 1
    `/usr/local/bin/pip3` calls `/usr/local/lib/python2.7`. This either means that `pip3` is being executed by a Python 2 (due to its shebang probably), or whatever Python is executing `pip3`, it's `sys.path` is wrong. – ivan_pozdeev Mar 16 '18 at 02:55
  • The script `/usr/local/bin/pip3` seems to be broken — it tries to use `/usr/local/lib/python2.7/` library. Use `python2.7 -m pip` or `python3.4…` to run `pip` with the proper version of Python. – phd Mar 16 '18 at 02:57
  • @phd I use the `python2.7 -m pip freeze` or `python 2 -m pip freeze`. Then, I got an error `/usr/bin/python2.7: cannot import name HashMissing; 'pip' is a package and cannot be directly executed`. But, `python 3.4 -m pip freeze` or `python3 -m pip freeze` are ok. – jefferyear Mar 16 '18 at 03:27
  • @phd I had installed a module(package). But, I forget I used python2 or python3 to install it. How to get known it? Otherwise, I know the module(package) path /usr/local/lib/python2.7/dist-packages/ and what I am looking for a module(package) right on there. But, where is the python3's path? It makes me feel confused on its path. The command `python -m site` show up the python2.7's path. However, where is the python3's? There is the error-`raise ImportError('This package should not be accessible on Python 3. '` – jefferyear Mar 16 '18 at 04:48
  • It can be neglected the matter on checking where is the path of python package. Import sys on interactive mode and then type `sys.path`. The answer is written as below. – jefferyear Mar 16 '18 at 06:16

1 Answers1

0

The result is the conflict without a specific command. Use python2.7 -m pip or python2 -m pip for a specific command. Vice versa, on python3, use python3 -m pip or python3.4 -m pip for a specific command.

In addition, use python or python3 to get into interactive mode. Then, use import sys and sys.path to get the path of python package.

jefferyear
  • 117
  • 7