8

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

J Edward Hammond
  • 509
  • 1
  • 3
  • 12
  • 1
    For me, I made a very silly mistake, forgot that I am using Linux, so it would be `pip3` not `pip`, – Aditya Rajgor Apr 24 '22 at 05:33
  • I was just a beginner when I made this post--it's amazing how much I've learned since then, but makes me feel better seeing how many people have made a similar error! – J Edward Hammond Apr 25 '22 at 14:18

3 Answers3

13

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

John Hedengren
  • 12,068
  • 1
  • 21
  • 25
  • One other thing to mention for those without administrative privileges to install for all users, the ```--user``` option can be added to the pip install command for local installation such as with ```pip3 install --user gekko```. – John Hedengren Jun 12 '19 at 23:15
2

I figured out the problem: apparently in later versions of Python (I'm using 3.7) the string for the terminal doesn't need python. I also didnt need to use the -m do declare pip a module as it isn't a module.

The string that worked:

pip install gekko
J Edward Hammond
  • 509
  • 1
  • 3
  • 12
2

I was facing the same problem, but

$python -m pip install gekko

worked for me.

Pratika
  • 91
  • 1
  • 6