Gurobi optimizer on python - python

I need a free optimizer for python. I use PYCharm and python 3.6 (I have python 2.7 on my lap top too)
Now, want to install Gurobi optimizer in PYCharm. but there are some problems:
when I wanted to install "gurobipy" library, the first error was on pip version. It was 9.0.3 and I had to upgrade that to 10.0.1. I've done that successfully and now when I want to install gurobipy, its error again: (AttributeError: module 'pip' has no attribute 'main')
After a quick search, I found that this is a problem of pip 10.0.1
And now I'm really confused. Can anyone help me? I really need this optimizer on python

I see people with the pip 10.0.1 issue downgrading pip version via python -m pip install --upgrade pip==9.0.3. So, how about using the pip 9.0.3 and an older gurobipy (like gurobipy==x.x.x) which might work with the older pip?
EDIT:
How to install gurobipy 8.0.1 for python without conda on Linux
Register an account on the Gurobi official website and login.
Download the latest version from the website.
Extract the package and go to the directory that contains the file setup.py
Run sudo python setup.py install
Add the following lines to your
.bashrc files:
export GUROBI_HOME="/path/to/gurobi801/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
or to run from PyCharm, you need to set LD_LIBRARY_PATH manually on the app like this
Test with import gurobipy

Related

python library install Questions

I use Python and pycharm as a tool.
If you use the pip statement to install the library, you will get an error.
For example, if I want to download the torch (1.6.0) version and type pip install torch==1.6.0,
It says no version.
This is not the end, but some libraries continue to cause strange conflicts and will not be installed.
For example, if you type pip install poro to install the poro library, an unknown error pops up and the installation fails.
I'm not asking for a pororo installation.
My question is, I want to know how to download the library without relying on pycharm.
I want to download it separately from a site like pypi and put the library directly into the virtual environment (conda).
What should I do?
The following worked for me:
First, install mkl using conda:
conda install -c anaconda mkl
Then run this:
conda install -c pytorch pytorch

EnvironmentError when trying to install tensorflow-nightly in venv in PyCharm

My problem is already mentioned here, however I don't know how to do it in my venv using PyCharm. I set up a venv in PyCharm as follows:
Normally if I want to install a package I click on + search for it and install it. So tried for tensorflow-nightly. However, when trying to do so, I get the following error:
Now I don't know what to do. I want to install this version into my venv. How to do that? Where should I run pip install tf-nightly --user to make it available in my venv? When I try to run this in PyCharm I get an error: SyntaxError: invalid syntax.
When installing it, does this change my Python version?
Do you have any Python processes running in PyCharm (debugger?) or outside of it which are using this specific venv? Looks like you do and this process is using numpy.
When you are trying to install tensorflow pip attempts to uninstall numpy first as the current version is not compatible with the desired tf version. Uninstallation clashes with the Python process which is holding some numpy files resulting in permission error and half working numpy as a result.
Check the package list, is there ~umpy package? I remember seeing a similar issue with matplotlib and it manifested itself in ~atplotlib package after a failed uninstallation attempt.
Long story short - stop all Python process running and:
either manually remove d:\tfexam\venv\lib\site-packages\~umpy and install tf again
or recreate the venv from the scratch
Where should I run pip install tf-nightly --user to make it available in my venv?
You are supposed to run it in the terminal with the activated venv. Though, it is a non-relevant suggestion in this specific case. Anyway, I would suggest reading some docs about pip and virtualenv management if you are not familiar with them, as these topics are essential and will save you the trouble later.
tf-nightly is an unstable version.
Use this:
pip install --upgrade tensorflow
And verify install
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

Pip inside virtual environment throws error

I am using virtual environment in python. When I use pip list command or any command to install packages it throws an error.
from pip._internal.distributions import (
ModuleNotFoundError: No module named 'pip._internal.distributions'
When I check the version pip -V inside venv it shows the version of pip (i.e. no error, working great). But, it is not working in any other commands. Please ask if I did not make it clear.
Thank you!!!
EDIT:-
I am using Windows 10 Pro. I installed python from their official website of version 3.8.1 using the windows installer. And, my pip version is 20.0.2 I installed pip by adding get-pip.py in bin file. I think there should not be any problem.

Anaconda installation of Tensorflow fails with Debian 8 VirtualBox

I'm trying to install Tensorflow.
I created a fresh Debian 8 VirtualBox for this purpose. Following the instructions here I downloaded and installed Anaconda with Python 3.
I created a conda environment for Tensorflow and activated it.
When trying to pip install Tensorflow it fails:
(tensorflow)$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl
The error is
not a supported wheel on this platform
I found a similar thread where a person had this problem with Python 2.7 and VMware, but their solution didn't work for me (and also not for another person who commented that they were using VirtualBox).
I also tried specifying pip3 and pip3.5 rather than just pip.
This appears to be a "known" issue from the following issue. Which paraphrased you should be able to download https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl and change the name of the .whl to tensorflow-0.8.0-py3-none-linux_x86_64.whl and install it correctly. There has been a change to the github documentation for Tensorflow to set the python version to 3.4 instead of 3.5. However, it appears this change hasn't made it to Tensorflow.org's documentation
# Python 3.4
$ conda create -n tensorflow python=3.4

Problems installing TensorFlow on Mac

I am trying to follow to the installation guide on tensorflow.org and have installed Python version 2 again for that reason using Homebrew.
When I run the installation as described
$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
I get this error message:
tensorflow-0.5.0-py2-none-any.whl is not a supported wheel on this platform.
I am obviously doing something wrong, but have no idea. Any clues?
I do not want to use virtualenv, since anaconda already comes with its own environment management conda. When installing the newest version 0.6.0 directly with pip install, I had a similar error. It seemed to not resolve the dependencies correctly.
Here is what you can try:
Install anaconda
Create a new conda workspace
Download the specific protobuf version that tensorflow needs: https://pypi.python.org/pypi/protobuf/3.0.0a3
Install it via sudo easy_install ~/Downloads/protobuf-3.0.0a3-py2.7.egg
Install a numpy version greater than 1.08.x via conda install numpy
Download the 0.6.0 version of tensorflow: https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py2-none-any.whl
Install via pip install ~/Downloads/tensorflow-0.6.0-py2-none-any.whl
When you install tensorflow from the whl file directly, it should tell you when dependencies are not there. It seems not to be able to resolve these conflicts independently. My setup had issues with protobuf and numpy. After installing them manually everything worked fine.
I hope this helps!
It seems to be a common issue. Try to install it in the virtualenv. Its a much better solution, as you can always easily set up a new version of tensorflow without conflicts.
VirutalEnv Tutorial:
http://tensorflow.org/get_started/os_setup.md#virtualenv-based_installation
On the Mac, I didn't have any problem installing tensorflow with the anaconda version of python: https://www.continuum.io/downloads
The anaconda version also provides science, math, engineering, and data analysis packages. A lot of people on https://www.kaggle.com/ seem to use this...just a thought.

Categories

Resources