Installing scikit-learn 0.15 (Python) - python

I'm currently using scikit-learn 0.14.1, which I installed using pip. I'm running Python version 2.7.6 (64 bit), using Canopy Enthought as my IDE. My operating system is OSX 10.9.2
Currently, I am trying to install scikit-learn 0.15. I cloned the repository into my home directory, cd'ed into it, and typed 'python setup.py install' into the command line.
I got an error saying:
error: could not delete '/Users/*****/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sklearn/__check_build/__init__.py': Permission denied
Anyone have any advice on how I should go about installing scikit-learn 0.15? Should I have cloned the directory into /Users/*****/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/ ?
Thanks so much!

A way of installing many python packages, amongst which scikit-learn, without needing root priviledges is to install it locally
python setup.py install --user
which will write information to ~/.local.
A second option is
python setup.py develop
which will compile in place and place a symbolic link in /Users/*****/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/. You may have to sudo and you may have to delete the old sklearn.
A third, more explicit way of doing this is to place the symbolic link yourself, which will require surgical, but very localized use of sudo for placing the link and removing the old scikit learn.
Assuming you cloned into ~/scikit-learn/
cd ~/scikit-learn
make in
cd /Users/*****/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/
sudo mv sklearn sklearn_
sudo ln -s ~/scikit-learn/sklearn sklearn
More detailed information on the website about installing in general and installing the bleeding edge

Related

PaddleOCR Error flag 'flagfile' was defined more than once

Am encountering an issue running PaddleOCR on M1 Macbook
ERROR: flag 'flagfile' was defined more than once (in files '/Users/paddle/xly/workspace/f2bafd01-b80e-4ac8-972c-1652775b2e51/Paddle/build/third_party/gflags/src/extern_gflags/src/gflags.cc' and '/tmp/gflags-20211021-3963-1mi18ai/gflags-2.2.2/src/gflags.cc').
This is related to the new version 2.6. With 2.5 you can use the wheel with the M1 (maybe you will need to debug some of the dependencies).
The good news is I've just installed PaddleOCR 2.6.1.2 on my Mac, right now.
You have two options:
You can upgrade to Python 3.10 (I am using 3.10.8) and then this error is gone
You can stick to Python 3.9 or lower and install PaddleOCR manually
If you want to continue with Python 3.9 or lower, then instead of installing via pip or conda, you do it manually by building the egg locally (it is an egg and not a wheel because it is using setuptools).
Assuming you already have a conda env or similar (mine has Python 3.10 and paddlepaddle 4.2.1, you'll probably need to install setuptools), you proceed as follows:
git clone https://github.com/PaddlePaddle/PaddleOCR.git
cd PaddleOCR
conda install --file requirements.txt
python setup.py install
After this you can use PaddleOCR on that environment.
Dependencies that can bring on some issues are Shapely, PyMuPDF, protobuf... Anyway I believe this whole issue will be fixed in the next release and then we will be able to use the wheel as-is.
MAC M1 chip can't follow Paddle's document step by step. I solve it by downloading the source code and recompiling it
https://juejin.cn/post/7189617837424672805

How to install Gurobi in python 3?

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

Install a Python package that built for Windows and MacOS on Linux

I have currently used the python Package Larch (https://pypi.python.org/pypi/larch) on Windows. It works nicely and I am really impressed with its performance. To use the package with some large models I want to install it on a Linux server (Ubuntu 14.04.4) where I do not have the root permissions. Though knowing that the OS requirements for the package are Window or MacOS and being a beginner with Linux, I still gave it a try.
I was able to install python locally using anaconda distribution but when I used pip to install larch, I got the following message
Could not find a version that satisfied the requirement larch (from version: )
No matching distribution found for larch
So it seems to me that I can not just deliberately try to install the package on linux with out any additional work. I then tried to find solutions for my issue but I could not find any. Therefore I would like to ask if there is any workaround for my problem?
Thank you so much for your help!
[Edit]
larch does not support python2.x, and only support Windows, MACOSX.
For installing in Linux, I suggest to use wine to run windows python program with larch.
For more information about wine in Ubuntu. You can search with keyword such as How To Run Windows Software on Ubuntu with Wine
For installing in macosx. Making sure your environment have python3. You can use which python3 to check that.
$ which python3
/usr/local/bin/python3
Then, without root permission, you can install package via virtualenv. (A workstation should provide this command)
$ virtualenv -p $(which python3) env
$ . env/bin/activate
(env) $ python -V
Python 3.x.x
And finally, you can install larch via pip.
(env) $ pip3 install larch
For more information about virtualenv
"Larch can be installed from source code. If not using Anaconda, this is necessary for Linux, and can be done for other systems as well.
The latest releases of the source code will be available from Larch releases (github.com). In addition, you can use git to grab the latest development version of the source code:git clone http://github.com/xraypy/xraylarch.git" After unpacking the source distribution kit, installation from source on any platform is:
python setup.py install
source:http://cars.uchicago.edu/xraylarch/installation/index.html
edit: See this for doing this without root access
How to install python modules without root access?

Scikit-learn tutorial documentation location

I have scikit-learn 0.16.1 installed on Ubuntu 14.04 and am working through the tutorial. SKL was installed with all default configuration. The tutorial states
The source of this tutorial can be found within your scikit-learn folder:
scikit-learn/doc/tutorial/text_analytics/
I've used find on my entire drive and there is no "tutorial" folder. Not anywhere. Anybody know where these files are really installed?
Finding the package contents
Where the packages are installed depends on how you installed scikit-learn
If you used Ubuntu's package system via
sudo apt-get install python-sklearn python-sklearn-doc
(you often need the doc package to get the accompanying documentation), then the tutorial is simply missing. The doc/-folder it is not contained in the python-sklearn-doc-package. See the bug report.
You can find out the contents of the package via
dpkg-query --listfiles python-sklearn-doc
If you used the Python Package Index to install it via
pip install --user --install-option="--prefix=" -U scikit-learn
, then the installation should be at $HOME/.local/lib/python2.7/site-packages/sklearn. (as also of pip show -f scikit-learn) But a
find . | grep -i tutorial
did not find any tutorial/-folder.
If you installed it from source, consider reinstalling via pip, as the warning states that
Warning
Packages installed with the python setup.py install command cannot be
uninstalled nor upgraded by pip later. To properly uninstall
scikit-learn in that case it is necessary to delete the sklearn folder
from your Python site-packages directory.
Solution
A solution would be to use the source. Either download the master file or do it via git:
git clone https://github.com/scikit-learn/scikit-learn.git
The git archive is more than 60 MiB, so you might want to prefer the master zip.

Trouble installing scipy despite having python2.7 and numpy installed already

I'm having trouble installing scipy via the binaries provided at http://sourceforge.net/projects/scipy/files/scipy/
Double clicking on the mpkg file after mounting the dmg installer gives the following error:
"scipy 0.13.0 can't be installed on this disk. scipy requires System Python 2.7 to install"
However, I already have python 2.7 and numpy installed. The python 2.7 came default with OSX Lion, so I assume it is System Python. With other python modules, one normally can download the binary then run
python setup.py install
Is there a way to cd through the mpkg file and locate a setup.py? Any advice install via this dmg installer?
I know there are other ways to manage python modules, like port and brew. However, I already installed a bunch of packages through setup.py, and I couldn't figure out how to get port to recognize those packages (for example, it will try to reinstall python and numpy via port)
Thanks!
If you have Mavericks and XCode 5, then you'll have to install Command Line Tools manually from the Apple Developer Site. I found this helpful post
You've got a few misconceptions here.
With other python modules, one normally can download the binary then run python setup.py install
No, that's what you do with source packages.
Is there a way to cd through the mpkg file and locate a setup.py?
No. What's inside an mpkg are pkg files. Which are filled with xar archives filled with cpio archives. Inside there is the built version of SciPy—that is, the files that setup.py would have copied to your site-packages if you'd run it—not the source package.
But you can download the source package yourself.
Or, better, let pip (or easy_install, but pip is better) download and run the setup.py for you.
Any advice install via this dmg installer?
If it won't work, my advice would be to not use it, and instead install with pip.
This blog post explains it, but I'll give you the details relevant to you below.
I know there are other ways to manage python modules, like port and brew. However, I already installed a bunch of packages through setup.py, and I couldn't figure out how to get port to recognize those packages.
You can't. MacPorts will not touch your system Python; it builds its own separate Python 2.7, with a completely independent site-packages directory and everything else. You would have to reinstall everything for this second Python 2.7. And deal with the confusion of having two Python 2.7 installations on the same machine.
Don't do that unless you absolutely have to.
In fact, if you want to use Homebrew for anything (and you do, see below), uninstall MacPorts, unless you really need it for something.
So, here are the steps:
Uninstall MacPorts.
I assume you already have Xcode and its Command Line Tools.
I assume you already have Homebrew.
Install a Fortran compiler with brew install gfortran.
Lion's Python 2.7 comes with easy_install, but not pip. So sudo easy_install pip to fix that. While you're at it, I'd suggest sudo easy_install readline, because you'll want that for ipython, and it won't work right with pip.
Apple's pre-installed NumPy has to be upgraded, and rebuilt with Fortran support, to make SciPy work. Fix that with sudo pip install --upgrade --force-reinstall numpy.
If you want ipython, pandas, etc. sudo pip install each of them as well.
In case you're considering upgrading soon, the exact same steps worked for me with OS X 10.9.0, except for some extra work to get the Xcode 5 command line tools set up.

Categories