Using Gurobi 8.1.0 in PyCharm

Hello everyone:)
I need Gurobi for some optimization problems and downloaded version 8.1.0 and installed the package in my terminal (I am using  Mac). In the terminal Gurobi seems to work. I would like to use it within Pycharm though.
My first command  "from gurobipy import *" leads to the follwoing error:
ModuleNotFoundError: No module named 'gurobipy'
In Jupyter Notebook the code works fine...
Can anyone help me with this?
Thank you in advance and kind regards

Hello Kristina,

Do you have it listed among other packages in your Project Interpreter (Preferences | Project | Project Interpreter)?

If not, you are probably using different interpreters in PyCharm and in the system terminal.


Hello Sergey,

thank you very much for your reply. Where and how do I change that? I am still very new to PyCharm and Gurobi.

Thanks in advance for your help!


First of all, you need to know which interpreter is currently used in your system terminal (the one with Gurobi installed). To do so, you can run which python in system terminal  and then go to Preferences | Project | Project Interpreter in PyCharm and add this interpreter (here is documentation on how to configure interpreters).

Another way is to install Gurobi to your current project interpreter in PyCharm. Please see our tutorial on how to install/uninstall/upgrade packages in PyCharm.

I suppose you need to install gurobipy package.


After running "which python" it showed the following:  /Applications/anaconda3/bin/python

When I put that into the interpreter of PyCharm it says /Applications/anaconda3/bin/python: can't open file 'create': [Errno 2] No such file or directory

What did I do wrong? Would it help to unistall Anaconda and Gurobi and download again? What do I have to keep in mind when doing so to make sure they all use the same interpreter?

Thank you very much for your patience!


>When I put that into the interpreter of PyCharm it says /Applications/anaconda3/bin/python: can't open file 'create': [Errno 2] No such file or directory

Where did you paste that?

I guess you should just browse to that python executable like this:

By the way, have you tried to install Gurobi to your current Project Interpreter?


Thank you so much! I followed the link and it is now working!

Gurobi opens perfectly in PyCharm now. I started working with the optimization by trying a very simple example:

from gurobipy import *

m = model()
x = m.addVar (vtype=GRB.BINARY, name="x")
y = m.addVar (vtype=GRB.BINARY, name="y")
z = m.addVar (vtype=GRB.BINARY, name="z")

m.setObjective(x+y+2*z, GRB.MAXIMIZE)


I get the following mistake in the m=model() line: NameError: name 'model' is not defined

Can you help me with that as well?

Thank you and kind regards :)



The error message indicates that model() is not defined in your code.

If you would like to return something from model() function and put it inside variable, then you should obviously write this function beforehand.

Something like this:

test_var = 12

def model():
return test_var

m = model()

It's rather Python related question than PyCharm.


Perfect, thank you!

I will try implementing that into my model.

Where can I post questions like this concering the code?

Thank you for all your time!


You are welcome!

Actually, any python related forum. You could use You may also find useful Python FAQ.


Hi friends.
I am using Pycharm 2018.3 and my problem is to install gurobipy. at the frist step, the error was pip version that upgraded from 10.0. to pip 19.0.3.
still, I receive an error in command window
" could not find a version that satisfies the requirement gurobpy (from version:)
no matching distribution found for gurobipy"
that's all wasted whole a day from start to write this post.
anybody can help me to install gurobipy on pycharm?



Hi @Hamedjabarian,

Please open the terminal in PyCharm and try to install manually with `pip install <module_name>`,

If you'll see the same error, it's probably package specific and not IDE-related, in which case you should ask the module developer/community for help.



i am having the same problem as @Hamedjabarian, i've been struggling to install the gurobipy package on pycharm but it didn't work it shows me the same error message.


Hi Marouane,

Have you tried to install it from the system terminal? Do you get the same error message?


yeah i have tried it from the system terminal and it's still the same error message


It means that the problem is not related to PyCharm. Please search the package-related forums for similar problems.


what i knew is that this package cannot be installed using pip


Please sign in to leave a comment.