Search code examples
pythongekko

How to fix 'can't open file 'pip': [Errno 2] No such file or directory' when installing gekko


I'm trying to install the gekko module in my python terminal using

python install -m pip gekko

but it is throwing an error not recognizing pip:

can't open file 'pip': [Errno 2] No such file or directory.

I'm using the terminal in Pycharm with Python 3.7


Solution

  • You may have just switched the order:

    python -m pip install gekko
    

    Installing from the command line with pip is okay as well:

    pip install gekko
    

    If you have multiple versions of Python (such as 2.7 and 3+), sometimes you want to specify that it is for Python 3+:

    pip3 install gekko
    

    Another way to install Gekko in Python is to install from a Python script:

    try:
        from pip import main as pipmain
    except:
        from pip._internal import main as pipmain
    pipmain(['install','gekko'])
    

    although this isn't the preferred option. See Installing python module within code