I am using python 3.6 version and CPLEX 12.10 in MAC with Anaconda. How do I access the cplex libraries for python? I have an academic version installed in my MAC and can be used independently in GUI.
What do you want to use ? There are the CPLEX python api which is a python API to the
matrix interface of CPLEX - And there is docplex, which is the object oriented modeling
layer based on CPLEX.
In anycase, if running a solve showed the error of promotional version, then it means
that somehow you installed the cplex package in the past.
Before you start, please open a Terminal console and make sure it is setup to use
your installation of Anaconda, and that your conda environment is activated (if you use one).
First you want to install whatever cplex was installed using conda uninstall cplex if you installed using conda or pip uninstall cplex if you were using pip.
Then you have a choice. Either you add $CPLEX_STUDIO_DIR1210/cplex/python/3.6/x86-64_osx to your PYTHONPATH or you install the CPLEX python wrappers:
$ cd $CPLEX_STUDIO_DIR1210/cplex/python/3.6/x86-64_osx
$ python setup.py install
as said in http://ibmdecisionoptimization.github.io/docplex-doc/mp/getting_started_python.html
conda install -c ibmdecisionoptimization docplex
should help
Related
Closely related to Can I conda install an alpha or beta version of Python? but that question is about a specific version in conda-forge. If a Python release (e.g. 3.10.0b1) is available for download via https://www.python.org/download/pre-releases/ but not in the main anaconda or any other conda channel yet, what are my best bets for using it?
Open an issue at conda-forge?
Some generic conda install script to run the python installer inside an environment?
Something else...
Particularly with alpha/beta releases of Python, I'd like the protection of a conda environment for my installation. I'm worried about using the standard Python installer now as it might not play nicely, but maybe there are some mitigation measures I can take?
pyenv is probably the best way to manage Python installations (not to be confused with Python virtual environments). It can easily install and access alpha and beta versions of Python, or whatever other previous versions have been published.
Unfortunately, pyenv does not work in Windows outside the Windows Subsystem for Linux. Fortunately, you can use pyenv-win, which is a port of pyenv for Windows, and is recommended by the authors of pyenv. To install it, follow their installation instructions.
Once you've got it installed, you can run the following to install Python 3.10.0b1:
pyenv install 3.10.0b1
pyenv global 3.10.0b1
Note that alpha/beta releases are not permanent, so when you actually run these commands 3.10.0b1 may no longer be available. You can run pyenv update to update pyenv, which will inform it of the currently available versions. pyenv install 3.10.<TAB><TAB> will show you which versions of Python 3.10 can be installed.
You can test it by running:
python -V
You should get an output of Python 3.10.0b1 if everything is in order.
To use Conda with pyenv, see this answer: https://stackoverflow.com/a/58045984/5946921
I'm using Windows and my default python version is:
python --version
Python 3.6.5 :: Anaconda, Inc.
Unfortunately, Gurobi is choosing 2.7 for installation.
How to install it with python 3.6?
You are in good shape because you have anaconda installed on windows. If you follow the instructions you will have gurobi installed with your version of python. As of today, the instructions are
conda config --add channels http://conda.anaconda.org/gurobi
conda install gurobi
If you still have trouble, read on. From reading your question, it looks like you might also have gurobi installed separately but in your path. This is probably OK as long as it is the same version of gurobi or if the anaconda distribution is ahead of the gurobi installation. Also, if you used the setup.py or pip to try to install gurobi, you might run into trouble from mixing pip and conda. In the worst case, it might be easiest just to delete and reinstall conda.
I tried to install the gurobi package on python 3 but it didn't work. The command that i am using on my macbook is:
pip install gurobipy, but it doesn't work, it shows me this:
ERROR: Could not find a version that satisfies the requirement gurobipy (from versions: none)
ERROR: No matching distribution found for gurobipy`
On macOS gurobipy is automatically installed in the system's python installation. If you need to install it within another python installation or virtual environment, too, then you need to install gurobipy like described at the end of this section in the quickstart guide. It boils down to going to the installation directory of Gurobi, and running an installer script:
(venv) bash-3.2$ cd /Library/gurobi811/mac64/
(venv) bash-3.2$ python setup.py install
fyi for pip installs:
use the following command for python 3.0+
python -m pip install -i https://pypi.gurobi.com gurobipy
obtain the relevant license and activate using grbgetkey (have to download gurobi install files from website to access grbgetkey as that's not installed using pip
copy the gurobi.lic file wherever you initially installed it to the following directory: [your python dir]/site-packages/gurobipy/.libs
**note there is an existing restricted install license in the directory, simply replace it.
Restart the kernel for python and the new license will be activated. No idea why Gurobi hasn't already published this info on their website for python pip installations.
Given that #Robert's answer focused on macOS, the solution below will work for Windows users. The installation process is as follows, per the Gurobi Documentation:
Step 1: Download and Install Anaconda -- see get anaconda for more details. Obviously, you can skip this step if you have Anaconda already installed (which is not uncommon if you are already a Python user).
Step 2: Install Gurobi into Anaconda, which can be done as follows:
The next step is to install the Gurobi package into Anaconda. You do this by first adding the Gurobi channel to your Anaconda channels and then installing the gurobi package from this channel.
From a terminal window issue the following command to add the Gurobi channel to your default search list:
conda config --add channels http://conda.anaconda.org/gurobi
Now issue the following command to install the Gurobi package:
conda install gurobi
Step 3: Install a Gurobi License The third step is to install a Gurobi license (if you haven't already done so).
In this link it is explainded the three ways of installing it. As the pip way is not working, it is possible to use the other ones. The anaconda way it is already covered in this Stackoverflow question. The third way it is also covered in this quiestion by Robert but he only says that this is for MacOs users. Window and Linux users do also get gurobipy installed after installing the optimizer
I am about to create a python interface in R with the package Reticulate. In order to access the python functions in R, the respective python packages need to be installed.
Two questions came to my mind:
1) If you use the reticulate package, does the Anaconda package need to be installed? Or is it sufficient to install the python packages only?
2) Is it possible to install python packages in R, similar to install.packages("r_package")?
Does anyone have experience with this Topic? Thanks in advance!
I'll add a little bit of nuance to the previous answer.
Like #f0nzie said, Anaconda is not a package, but a package manager. Ideally, you will create an environment using Anaconda to assist with your package management and version control. The documentation for conda environments is here.
Now, you can install python packages to your anaconda package in R. That is possible using reticulate::conda_install(envname, packages). The documentation for conda_install() can be found here.
1) The R package reticulate can work with the default python or with Anaconda2 or Anaconda3. If you want Anaconda to work with R, you will have to install Anaconda first. Once installed, you call the library(reticulate), and run py_config() or reticulate::py_discover_config(), that will give you the list of paths and environment used by the Python installation. Then, once you know the Python path, you add a line like this use_python("/opt/miniconda2/bin/python"), right after library(reticulate) and you are in business.
2) to install Python packages so R (or reticulate) can see them, you have to install them as regular Python packages from a terminal or console; not R. Example: conda install numpy to install numpy, or conda install scipy to install scipy, and so on.
I am just doing all this in a Docker container rocker/rstudio. It should be easier in a standard OS.
Here is step-by-step instructions: rstudio reticulate
Cheers!
In case you need a specific version of Python modules then place == after module name, e.g. the following will install specific versions of 3 modules using pip:
reticulate::conda_install(c("PyMuPDF==1.14.20", "PyPDF2==1.26.0", "reportlab==3.5.23"),
envname = "myenv", pip = TRUE)
What I did to try and solve this issue:
Using Mac OS X
Using Anaconda distro currently in my computer as the path /Users/hongshuhong/anaconda/
Used conda instead of virtualenv because of my distribution of python. I referred to the guide here and tried to download the same with conda's package manager: https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup
Tensorflow worked correctly when I created an anaconda env using the command conda create --name ML python=2.7 anaconda to state I'm using 2.7 python, then used this command conda install -c https://conda.anaconda.org/jjhelmus tensorflow
gathered from the Anaconda Cloud to attempt to download it. It worked when I said
$ python
>>> import tensorflow as tf
...
However, it doesn't really fix the issue:
However, I want to use the 3.5 distribution of python, simply to keep up with the times and not use outdated pythons.
I attempted to download it using the same way in python=3.5, but it raised this error when I tried to run the command conda install -c https://conda.anaconda.org/jjhelmus tensorflow :
Hint: the following packages conflict with each other:
- tensorflow
- python 3.5*
Use 'conda info tensorflow' etc. to see the dependencies for each package.
And I ran the conda info tensorflow to see what was going on and I got:
Fetching package metadata: ....
Error: No packages found in current osx-64 channels matching: tensorflow
This is really frustrating me and I'm not sure what to do. If there's no work around for this, I think I'll have to use Anaconda's python 2.7 distribution for TensorFlow experiments. If anyone has any idea how to solve this compatibility issue(or some other kind of issue), I'd be extremely grateful. Thanks.
EDIT: I'm pretty sure TensorFlow supports 3.5 because in their documentations they say they support 2.7 python and 3.3+. If there were no clues as to whether they support 3.5, I would have already given up and used 2.7 by now.
The version of TensorFlow packaged here is version 0.5.
Python 3.x support was introduced in TensorFlow 0.6, so you need to figure out how to install the newest version into Anaconda.
Usually you can install packages into anaconda using pip, but I haven't succeeded with TensorFlow.
EDIT: I just noticed that the documentation hasn't updated the url to the pip-wheel.
To install tensorflow in python 3.5 via pip, use the following command:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl
This links to ...tensorflow-0.5.0-py2-none-any.whl, which is an older version of tensorflow for python 2.x.
Tensorflow get started page link.