Closed mariaeileen closed 3 years ago
Hi,
You have that error because recent versions of pip
are just unable to uninstall cplex installed by older versions of pip.
Please install cplex using:
$ cd /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64_osx
$ python setup.py --ignore-installed install
This should just override the files and you should be set.
Best regards
Hmm I tried that, but it didn't seem to make any difference. Here is the full error message, might there be something wrong with site-packages?
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/cplex_engine.py", line 1906, in solve cpx.solve() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex/init.py", line 1329, in solve _proc.mipopt(self._env._e, self._lp) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex/_internal/_procedural.py", line 692, in mipopt check_status(env, status) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex/_internal/_procedural.py", line 236, in call raise CplexSolverError(error_string, env, status) cplex.exceptions.errors.CplexSolverError: CPLEX Error 1016: Community Edition. Problem size limits exceeded. Purchase at http://ibm.biz/error1016.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/solver7.py", line 99, in
Thanks for responding on my issue.
This is the output in the terminal when I type your suggestion: $ python setup.py --ignore-installed install usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help
error: option --ignore-installed not recognized
cplex
installation only add files in one directory. So what you can do is just manually remove the existing cplex with:
rm -rf /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex/
- then you can python setup.py install
. Can you please try that ?
Thanks for your response Now I get the following error message with several traceback error messages: import cplex #@UnresolvedImport ModuleNotFoundError: No module named 'cplex'
Traceback (most recent call last):
File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/solver7.py", line 99, in
Sorry, I realise that the previous comment is not my problem as that was run in python 3.8.
The error message I get for python 3.7 is: AttributeError: module 'cplex' has no attribute 'Cplex'
This is my pythonpath. As the IBM webpage informs, it should not be necessary to change the pythonpath for only one version of CPLEX, do you have any thoughts regarding my pythonpath?
for p in sys.path: print(p)
/Users/mariaeileenhubbuck/Documents /Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7 /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
Please let me know the values of:
which python
Then
echo $PYTHONPATH
Then:
ls -al /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex
AttributeError: module 'cplex' has no attribute 'Cplex'
means that there is a cplex directory but something was mis-installed.
I've also seen that error when cplex has been installed using pip install cplex
or python setup.py install
AND it is in PYTHONPATH as well.
Note: I will be off for Christmas and New Year vacations for 2 weeks, I will not be able to answer until my return.
Hi! Here is the output. As shown below, the output for "echo $PYTHONPATH" is nothing, only an empty line:
(base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ which python /Users/mariaeileenhubbuck/opt/anaconda3/bin/python
(base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ echo $PYTHONPATH
(base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ ls -al /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex total 0 drwxr-xr-x 3 mariaeileenhubbuck admin 96 Dec 20 12:45 . drwxrwxr-x 46 root admin 1472 Dec 20 12:45 .. drwxr-xr-x 3 mariaeileenhubbuck admin 96 Dec 20 12:45 lib
I implemented the following command to change the Pythonpath:
export PYTHONPATH="/usr/local/Cellar/python/3.7.0/bin/python3:$PYTHONPATH" (base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ echo $PYTHONPATH /usr/local/Cellar/python/3.7.0/bin/python3:
Your /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex
must be empty. There is a lib
directory here that does not look like anything cplex could have installed here ?
This is why you have the AttributeError: module 'cplex' has no attribute 'Cplex'
message.
Please remove that directory: rm -rf /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex
(please check there is nothing here, ls -al /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex
should end up with an error like directory not found, then install the CPLEX wrappers:
(base) $ cd /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/
(base) $ python setup.py install
Can you please copy the output of python setup.py install
so that we can check what went wrong, if it does not work ?
Thanks
Hi, I tried the above, but it didn't work. However, the error message now changed to FileNotFoundError: Could not load module from /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/cplex/init.py
(base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ cd /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64_osx/ (base) Marias-MacBook-Pro:x86-64_osx mariaeileenhubbuck$ python setup.py install running install running build running build_py running install_lib running install_egg_info Removing /Users/mariaeileenhubbuck/opt/anaconda3/lib/python3.7/site-packages/cplex-12.10.0.0-py3.7.egg-info Writing /Users/mariaeileenhubbuck/opt/anaconda3/lib/python3.7/site-packages/cplex-12.10.0.0-py3.7.egg-info (base) Marias-MacBook-Pro:x86-64_osx mariaeileenhubbuck$
As long as you have Could not load module from /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/cplex/init.py
, it means that somehow your python interpreter is trying to load a module from /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/
- This is only possible if that directory is in your PYTHONPATH. How do you run your programs, are you using an IDE ?
Thanks for your response, I'm using IDLE for Python 3.7.
From your shell environment, we know that you did not add /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/
in your PYTHONPATH. However, given your error, I believe that your IDE (IDLE) is adding that directory in your PYTHONPATH.
Please check the configuration of your IDE and remove that directory from the python path added by the IDE.
Note also that there is a configuration problem I think.
You have some error stack referring to /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
which is the location were system python install libraries.
Now your installation log says that cplex has been installed in /Users/mariaeileenhubbuck/opt/anaconda3/lib/python3.7/site-packages
, and your shell starts with (base)
something, which is the sign that you are using anaconda.
So it looks like you installed cplex with one python interpreter (anaconda ?) then your IDE is trying to use python from another interpreter (the system 3.7 ?).
Please first make sure that all your tools are using the same interpreter, otherwise there is just no way for me to help you if your python configuration is not right.
Thanks.
Ok thanks! I will look into the use of different interpreters!
Hi, I have installed the Academic version of CPLEX_Studio1210, but get the following error message: Problem size limits exceeded, CPLEX code=1016
I have followed the guidelines provided by IBM by implying $ cd /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64_osx in the terminal before the command python setup.py install.
I have typed in "pip uninstall cplex" as I have tried to install the free version earlier. However, I get the following message in terminal: $ pip uninstall cplex Found existing installation: cplex 12.10.0.0 ERROR: Cannot uninstall 'cplex'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Is this the reason for why it does not work? That I am unable to uninstall cplex? I highly appreciate your advice:)