I'm trying to install NumPy, so that I can use it in Python plug-ins for GIMP. Every time I try, it installs into the external Python, and the Python inside GIMP can't find it. How do I install NumPy, so that GIMP can find it?
If you are using the flatpak version, you can install numpy as a "user" package using your "general" pip installer (and not the apt kind) and it will be taken in account by Gimp's built-in runtime (just tested, it works). You may have to force a specific version to get a V2-compatible numpy:
pip install --user -I numpy==1.11.0
I cannot tell you how to install pip for your V2 python on 20.04. On my 19.04 apt install python-pip did the trick but on 20.04 it could be apt install python2-pip or you would have to install it by hand.
Related
It seems the COCO PythonAPI only support python2. But peoples do use it in python3 environment.
I tried possible methods to install it, like
python3 setup.py build_ext --inplace
python3 setup.py install
But python3 setup.py install will fail due to coco.py and cocoeval.py containning python2 print function.
Update: solved by updating the COCO PythonAPI project. Leave this question for people facing the same issue.
Try the following steps:
Use git clone to clone the folder into your drive. In this case, it should be git clone https://github.com/cocodataset/cocoapi.git
Use terminal to enter the directory, or open a terminal inside the directory
Type in 2to3 . -w. Note that you might have to install a package to get 2to3. It is an elegant tool to convert code from Python2 to Python3; this code converts all .py files from Python2-compatible to Python3-compatible
Use terminal to navigate to the setup folder
Type in python3 setup.py install
This should help you install COCO or any package intended for Python2, and run the package using Python3. Cheers!
I have completed it with a simple step
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
** before that you need to install Visual C++ 2015 build tools on your path
Install
Instead of the official version (which has issues with python 3) use an alternative one. Install it on your local machine, globally (i.e., outside any virtual environment). You can do this by:
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Check if it is installed globally:
pip freeze | grep "pycocotools"
You should see something like pycocotools==2.0.0 in your output.
Now, inside your virtual-env (conda or whatever), first install numpy and cython (and maybe setuptools if it's not installed) using pip, and then:
pip install pycocotools
Verify
Inside your project, import (for example) from pycocotools import mask as mask and then print(mask.__author__). This should print out the author's name, which is tsungyi.
Where Is It?
The installed package, like any other packages that are locally installed inside a virtual-env using pip, will go to External Libraries of your project, under site-packages. That means it is now part of your virtual-env and not part of your project. So, other users who may want to use your code, must repeat this installation on their virtual-env as well.
Troubleshooting:
The main source of confusion is that either you did not install the required packages before installing cocoapi, or you did install the required packages but for a different python version. And when you want to check if something is installed, you may check with, for instance, python3.6 and see that it exists, but you are actually running all your commands with python3.7. So suppose you are using python3.7. You need to make sure that:
python -V gives you python3.7 and NOT other version, and pip -V gives you pip 19.2.3 from /home/<USER>/.local/lib/python3.7/site-packages/pip (python3.7), that actually matches with your default python version. If this is not the case, you can change your default python using sudo update-alternatives --config python, and following the one-step instruction.
All the required packages are installed using the right python or pip version. You can check this using pip and pip3 to stop any differences that may cause an issue:
pip freeze | grep "<SUBSTRING-NAME-OF-PACKAGE>" or pip show <PACKAGE-NAME> for more recent versions of pip.
To install the required packages, after you made sure about (1), you need to run:
sudo apt install python-setuptools python3.7-dev python3-wheel build-essential and pip install numpy cython matplotlib
Environment:
The above steps were tested on Ubuntu 18.4, python 3.6.8, pip 19.0.3.
If you are struggling building pycocotools on Ubuntu 20.04 and python3.7
try this:
sudo apt-get install -y python3.7-dev
python3.7 -m pip install pycocotools>=2.0.1
There are alternative versions of the cocoapi that you can download and use too (I'm using python 3.5). Here's a solution that you might want to try out: How to download and use object detection datasets (e.g. coco or pascal)
here's how i did successfully! (the reason is the gcc version)
install the dependencies: cython (pip install cython), opencv (pip install opencv-python)
check the gcc version by this command: gcc --version
your output will be like this 'Command 'gcc' not found, but can be installed with:
sudo apt install gcc
'
Type the below commands to install the gcc:
sudo apt update
sudo apt install build-essential
sudo apt-get install manpages-dev
now check again the gcc version(step2)
if you get below output
'gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'
now run the code for pycocotools installations:
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
finally wait check if the installation is successful :
'Successfully installed pycocotools-2.0'
I used sudo apt-get install python-scipy to install scipy. This put all the files in /usr/lib/python2.7.dist-packages/scipy. My best guess is it chose that location because python 2.7 was the default version of python. I also want to use scipy with python 3 however. Does the package need to be rebuilt for python 3 or can I just point python 3 to the existing version?
I've tried using pip to install two parallel version, but I can't get the dependency libblas3 installed for my system.
What's the best way to do this?
I'm on Debian Jessie.
To install scipy for python3.x the on a debian-based distribution:
sudo apt-get install python3-scipy
This corresponds to the python2.x equivalent:
sudo apt-get install python-scipy
On a more platform-independent note, pip is the more standard way of installing python packages:
pip install --user scipy #pip install using default python version
To make sure you are using the right pip version you can always be more explicit:
pip2 install --user scipy # install using python2
pip3 install --user scipy # install using python3
Also, I believe anaconda or the more lightweight miniconda were intended to make installation of python packages with complex dependencies more easy, plus it allows for using an environment, making it easier to have several configurations with non-compatible versions etc. This would create+use a python binary different from the one on your system though.
One would then install scipy using the command conda:
conda install scipy
If installing scipy for a specific version you would create an environment with that python version:
conda create -n my_environment_name python=3 scipy
One could also use pip inside a conda environment alongside conda python packages, but I would make sure that you are using pip installed using conda to avoid conflicts. An added benefit when installing conda for a user, is that you don't have to add the --user flag when installing with pip.
If you can't find python3-scipy using apt-get you can use pip to install it for python3, you just have to make sure you use pip3 (if you don't have it apt install python3-pip
pip3 install --user scipy
You may want to try with pip3 install scipy
I want to draw a decision tree with python3. Yet I can only find modules for python2: graphviz, ete3
Did I miss something? Can I use them with python3? Do you know any other possibilities?
I use Ubuntu 14.04.
Edit:
I tried the command sudo python3 -m pip install graphviz, but it still can't find the module.
According to Graphviz's PyPI page, it is available for Python 3.
On Ubuntu make sure you have graphviz with:
sudo apt-get install python3-pygraphviz
Perhaps Python3 can't find your installed graphviz? Did you install it with, e.g.
python3 -m pip install graphviz
On Ubuntu you might try:
sudo apt-get install python3-pip
pip3 install graphviz
You haven't told us what your system is, which may affect the advice you are given.
If you're on Windows, I usually recommend installing Anaconda and using its package manager (it comes with almost all the things, but not graphviz so you'd have to use its package manager to install, but I'd expect it to work out of the gate once you did install it).
If you're on Mac or Linux, try installing with the command I gave above (or whatever your Python 3 executable uses.)
I'm trying making work scipy in my virtualenv but the only way to install it is with apt-get and there is not a way to install it for my virtual env. Doesn't exits a package for pil, so i tried copy the folder
/usr/lib/python2.7/dist-packages/scipy to /home/envs/conbert/lib/python2.7/site-packages but is not working. Is possible make work scipy for a specific environment?
You can install scipy using pip in your virtualenv with
pip install scipy
pip should install all Python dependencies necessary before installing scipy.
Note that you may have to install some extra non-Python dependencies using apt-get. These will be flagged as errors during the pip installation if they're necessary. Possible dependencies may include BLAS, LAPACK, ATLAS, various compilers, etc. Whether these are already installed will depend on what you've already done with your system.
I am using Ubuntu 12.04 and want to use python 3.4 side by side with python 2.7.
The installation of python 3.4 worked properly. However, I cannot install the numpy package for python 3 (and as a consequence I can't install scipy, pandas etc.).
Using
sudo pip3 install numpy
spits out the following error:
File "numpy/core/setup.py", line 289, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
Btw, I already have python-dev installed.
Moreover, installing numpy via
sudo apt-get install python-numpy
does not work either since I already installed numpy for python 2.7 and the installer responds that numpy is already up to date.
What can I do? Thanks!
You have not installed the Python 3 development package. Install python3.4-dev:
apt-get install python3.4-dev
The main package never includes the development headers; Debian (and by extension Ubuntu) package policy is to put those into a separate -dev package. To install numpy however, you need these files to be able to compile the extension.
Solved by incrementing the python-dev package until I hit the right one. May need to be incremented further in the future.
Poor implementation by python developers.
sudo apt-get install python3.7-dev