Selenium + Google Colab error: 'chromedriver' executable needs to be in PATH - selenium

I'm using the code offered by #korakot-chaovavanich in this thread How to use Selenium on Colaboratory Google?. I really need to have a solution to make it work on Google Colab.
# install chromium, its driver, and selenium
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
# set options to be headless, ..
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# open it, go to a website, and get results
wd = webdriver.Chrome('chromedriver',options=options)
wd.get("https://www.google.com")
print(wd.page_source) # results
I've tested in Google Colab, but I have no idea why it fails to work. I tried to look under /usr/lib but I couldn't find any "chromium-browser" folder. I can't figure where chromedriver is being installed to in Google Colab.
Error message from executing this code in Google Colab:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libnvidia-common-410
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
chromium-browser chromium-browser-l10n chromium-codecs-ffmpeg-extra
Suggested packages:
webaccounts-chromium-extension unity-chromium-extension adobe-flashplugin
The following NEW packages will be installed:
chromium-browser chromium-browser-l10n chromium-chromedriver
chromium-codecs-ffmpeg-extra
0 upgraded, 4 newly installed, 0 to remove and 16 not upgraded.
Need to get 68.5 MB of archives.
After this operation, 251 MB of additional disk space will be used.
Ign:1 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 chromium-codecs-ffmpeg-extra amd64 74.0.3729.169-0ubuntu0.18.04.1
Ign:2 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 chromium-browser amd64 74.0.3729.169-0ubuntu0.18.04.1
Ign:3 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 chromium-browser-l10n all 74.0.3729.169-0ubuntu0.18.04.1
Ign:4 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 chromium-chromedriver amd64 74.0.3729.169-0ubuntu0.18.04.1
Err:1 http://security.ubuntu.com/ubuntu bionic-updates/universe amd64 chromium-codecs-ffmpeg-extra amd64 74.0.3729.169-0ubuntu0.18.04.1
404 Not Found [IP: 91.189.88.31 80]
Err:2 http://security.ubuntu.com/ubuntu bionic-updates/universe amd64 chromium-browser amd64 74.0.3729.169-0ubuntu0.18.04.1
404 Not Found [IP: 91.189.88.31 80]
Err:3 http://security.ubuntu.com/ubuntu bionic-updates/universe amd64 chromium-browser-l10n all 74.0.3729.169-0ubuntu0.18.04.1
404 Not Found [IP: 91.189.88.31 80]
Err:4 http://security.ubuntu.com/ubuntu bionic-updates/universe amd64 chromium-chromedriver amd64 74.0.3729.169-0ubuntu0.18.04.1
404 Not Found [IP: 91.189.88.31 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_74.0.3729.169-0ubuntu0.18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.31 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-browser_74.0.3729.169-0ubuntu0.18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.31 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-browser-l10n_74.0.3729.169-0ubuntu0.18.04.1_all.deb 404 Not Found [IP: 91.189.88.31 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-chromedriver_74.0.3729.169-0ubuntu0.18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.31 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
cp: cannot stat '/usr/lib/chromium-browser/chromedriver': No such file or directory
Requirement already satisfied: selenium in /usr/local/lib/python3.6/dist-packages (3.141.0)
Requirement already satisfied: urllib3 in /usr/local/lib/python3.6/dist-packages (from selenium) (1.24.3)
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self)
75 stderr=self.log_file,
---> 76 stdin=PIPE)
77 except TypeError:
4 frames
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self)
81 raise WebDriverException(
82 "'%s' executable needs to be in PATH. %s" % (
---> 83 os.path.basename(self.path), self.start_error_message)
84 )
85 elif err.errno == errno.EACCES:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

The problem comes from a version mismatch between Google Chrome and Chromium Browser, leading to the command apt install chromium-chromedriver to fail. It is probably due to an update from Selenium.
You need to update every packages with the command apt-get update, to avoid version mismatch of your tools.
Try this on colab:
# install chromium, its driver, and selenium
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
# set options to be headless, ..
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# open it, go to a website, and get results
wd = webdriver.Chrome('chromedriver',options=options)
wd.get("https://www.website.com")
print(wd.page_source) # results

Related

Selenium use chrome on Colab got unexpectedly exited

I have been using selenium chromedriver in google colab for a while.
Today I start my work, I get the error never got before.
I'm wondering if this error is related to the chromedriver version.
This is install log today
!apt-get update
!apt install -y chromium-chromedriver
Get:1 focal-updates/main amd64 apparmor amd64 2.13.3-7ubuntu5.1 [494 kB]
Get:2 focal/main amd64 liblzo2-2 amd64 2.10-2 [50.8 kB]
Get:3 focal-updates/main amd64 squashfs-tools amd64 1:4.4-1ubuntu0.3 [117 kB]
Get:4 focal-updates/main amd64 snapd amd64 2.57.5+20.04ubuntu0.1 [37.6 MB]
Get:5 focal-updates/universe amd64 chromium-browser amd64 1:85.0.4183.83-0ubuntu0.20.04.2 [48.3 kB]
Get:6 focal-updates/universe amd64 chromium-chromedriver amd64 1:85.0.4183.83-0ubuntu0.20.04.2
...
...
(Reading database ... 129791 files and directories currently installed.)
Preparing to unpack .../chromium-browser_1%3a85.0.4183.83-0ubuntu0.20.04.2_amd64.deb ...
=> Installing the chromium snap
==> Checking connectivity with the snap store
===> System doesn't have a working snapd, skipping
Unpacking chromium-browser (1:85.0.4183.83-0ubuntu0.20.04.2) ...
Selecting previously unselected package chromium-chromedriver.
Preparing to unpack .../chromium-chromedriver_1%3a85.0.4183.83-0ubuntu0.20.04.2_amd64.deb ...
Unpacking chromium-chromedriver (1:85.0.4183.83-0ubuntu0.20.04.2) ...
Setting up chromium-browser (1:85.0.4183.83-0ubuntu0.20.04.2) ...
update-alternatives: using /usr/bin/chromium-browser to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/chromium-browser to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode
Setting up chromium-chromedriver (1:85.0.4183.83-0ubuntu0.20.04.2) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
Processing triggers for systemd (245.4-4ubuntu3.19) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for dbus (1.12.16-2ubuntu2.3) ...
This is install log yesterday
Get:1 bionic-updates/universe amd64 chromium-codecs-ffmpeg-extra amd64 108.0.5359.71-0ubuntu0.18.04.5 [1,159 kB]
Get:2 bionic-updates/universe amd64 chromium-browser amd64 108.0.5359.71-0ubuntu0.18.04.5 [83.6 MB]
Get:3 bionic-updates/universe amd64 chromium-browser-l10n all 108.0.5359.71-0ubuntu0.18.04.5 [5,230 kB]
Get:4 bionic-updates/universe amd64 chromium-chromedriver amd64 108.0.5359.71-0ubuntu0.18.04.5 [5,594 kB]
...
...
Setting up chromium-chromedriver (108.0.5359.71-0ubuntu0.18.04.5) ...
Setting up chromium-browser-l10n (108.0.5359.71-0ubuntu0.18.04.5) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
I found the colab system is updated to ubuntu 20.04 from 18.04.
Is this the reason why chromedriver cannot be used?
How should I do to solve this problem?
Thanks.
These log messages...
Get:1 bionic-updates/universe amd64 chromium-codecs-ffmpeg-extra amd64 108.0.5359.71-0ubuntu0.18.04.5 [1,159 kB]
Get:2 bionic-updates/universe amd64 chromium-browser amd64 108.0.5359.71-0ubuntu0.18.04.5 [83.6 MB]
Get:3 bionic-updates/universe amd64 chromium-browser-l10n all 108.0.5359.71-0ubuntu0.18.04.5 [5,230 kB]
Get:4 bionic-updates/universe amd64 chromium-chromedriver amd64 108.0.5359.71-0ubuntu0.18.04.5 [5,594 kB]
...
...
Setting up chromium-chromedriver (108.0.5359.71-0ubuntu0.18.04.5) ...
Setting up chromium-browser-l10n (108.0.5359.71-0ubuntu0.18.04.5) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
...is the result of an issue induced as the colab system is updated from v18.04 to ubuntu 20.04 LTS recently.
Quick Fix
#mco-gh created a new notebook following #metrizable's guidance
(details below) which is working perfect as of now:
https://colab.research.google.com/drive/1cbEvuZOhkouYLda3RqiwtbM-o9hxGLyC
Details
In the discussion Issues when trying to use Chromedriver in Colab #EvanWiederspan clearly mentioned:
We recently upgraded the Ubuntu version, which may be causing this.
After connecting to a runtime, can you try running "Use fallback
runtime version" from the command palette (ctrl + shift + p)
#metrizable in his comment further clarified:
I understand that you'd like to use selenium with chromium-browser
under Ubuntu 20.04 LTS. Although YMMV, since Ubuntu 20.04+ no longer
distributes chromium-browser outside of a snap package, you can
install a compatible version from the Debian buster repository
Sample code:
%%shell
# Ubuntu no longer distributes chromium-browser outside of snap
#
# Proposed solution: https://askubuntu.com/questions/1204571/how-to-install-chromium-without-snap
# Add debian buster
cat > /etc/apt/sources.list.d/debian.list <<'EOF'
deb [arch=amd64 signed-by=/usr/share/keyrings/debian-buster.gpg] http://deb.debian.org/debian buster main
deb [arch=amd64 signed-by=/usr/share/keyrings/debian-buster-updates.gpg] http://deb.debian.org/debian buster-updates main
deb [arch=amd64 signed-by=/usr/share/keyrings/debian-security-buster.gpg] http://deb.debian.org/debian-security buster/updates main
EOF
# Add keys
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A
apt-key export 77E11517 | gpg --dearmour -o /usr/share/keyrings/debian-buster.gpg
apt-key export 22F3D138 | gpg --dearmour -o /usr/share/keyrings/debian-buster-updates.gpg
apt-key export E562B32A | gpg --dearmour -o /usr/share/keyrings/debian-security-buster.gpg
# Prefer debian repo for chromium* packages only
# Note the double-blank lines between entries
cat > /etc/apt/preferences.d/chromium.pref << 'EOF'
Package: *
Pin: release a=eoan
Pin-Priority: 500
Package: *
Pin: origin "deb.debian.org"
Pin-Priority: 300
Package: chromium*
Pin: origin "deb.debian.org"
Pin-Priority: 700
EOF
# Install chromium and chromium-driver
apt-get update
apt-get install chromium chromium-driver
# Install selenium
pip install selenium
Note
Generally the following line of code will install the snap too:
sudo apt install chromium-chromedriver
incase it doesn't you have to manually install the snap using:
sudo snap install chromium
You can use this sample colab workbook to rebuild your script.
The reason is that the last Ubuntu update update supports chromium diver just via snap.
Post with explanation:
https://github.com/googlecolab/colabtools/issues/3347#issuecomment-1397277515
Direct Link to Notebook:
https://colab.research.google.com/drive/1cbEvuZOhkouYLda3RqiwtbM-o9hxGLyC
After the runtime status says connected, open the command palette (ctrl + shift + p) and select "Use Fallback Runtime Version"
That should resolve this issue!
Reference:
https://github.com/googlecolab/colabtools/issues/3347#issuecomment-1386349011
We recently upgraded the Ubuntu version, which may be causing this. After connecting to a runtime, can you try running "Use fallback runtime version" from the command palette (ctrl + shift + p) and seeing if your notebook works after that?
Better solution is to do this first in addition to your usual thing you do in colab to make selenium work:
!sudo add-apt-repository ppa:saiarcot895/chromium-beta
!sudo apt remove chromium-browser
!sudo snap remove chromium
!sudo apt install chromium-browser
Note: Solution provided here by #Johannes Stephan works but it crashes browser a lot and makes it unusable
FULL Code:
!sudo add-apt-repository ppa:saiarcot895/chromium-beta
!sudo apt remove chromium-browser
!sudo snap remove chromium
!sudo apt install chromium-browser
!pip3 install selenium
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')

How to fix geckodriver error when running InstaPy on raspberry pi OS?

I installed InstaPy recently and downloaded one standard script on the internet. I know that there is nothing wrong with opensource code and on forums it says to download geckodriver. However, I haven't found a suitable solution to install geckodriver so can you guys let me know the best way to fix this?
Error:
>>> %Run basic_follow_unfollow_activity.py
InstaPy Version: 0.6.13
._. ._. ._. ._. ._. ._. ._. ._.
Workspace in use: "/home/pi/InstaPy"
Error, unable to determine correct filename for 32bit linux
Traceback (most recent call last):
File "/home/pi/Desktop/basic_follow_unfollow_activity.py", line 36, in <module>
headless_browser=False)
File "/home/pi/.local/lib/python3.7/site-packages/instapy/instapy.py", line 338, in __init__
geckodriver_log_level,
File "/home/pi/.local/lib/python3.7/site-packages/instapy/browser.py", line 122, in set_selenium_local_session
driver_path = geckodriver_path or get_geckodriver()
File "/home/pi/.local/lib/python3.7/site-packages/instapy/browser.py", line 38, in get_geckodriver
sym_path = gdd.download_and_install()[1]
File "/home/pi/.local/lib/python3.7/site-packages/webdriverdownloader/webdriverdownloader.py", line 177, in download_and_install
show_progress_bar=show_progress_bar)
File "/home/pi/.local/lib/python3.7/site-packages/webdriverdownloader/webdriverdownloader.py", line 129, in download
download_url = self.get_download_url(version, os_name=os_name, bitness=bitness)
File "/home/pi/.local/lib/python3.7/site-packages/webdriverdownloader/webdriverdownloader.py", line 324, in get_download_url
raise RuntimeError(info_message)
RuntimeError: Error, unable to determine correct filename for 32bit linux
I tried following solutions:
This link on forum to install geckodriver - https://www.raspberrypi.org/forums/viewtopic.php?t=167292
Installed firefox ESR in terminal - sudo apt-get install firefox-esr
I've had similar problems to get the geckodriver running on my Pi. If i remember correctly there was a problem with the ARM support. I ended up switching to chromedriver.
you can easily install it with:
sudo apt install chromium-chromedriver
after that you can use it without any executable_path like this:
from selenium import webdriver
driver = webdriver.Chrome()
Installing Geckodrive instruction is given on instapy documentation through this link - https://github.com/InstaPy/instapy-docs/blob/master/How_Tos/How_to_Raspberry.md
GeckoDriver releases can be found in: https://github.com/mozilla/geckodriver/releases. The latest ARM release as of 2019-08-16 is v0.23.
Follow these steps:
1) wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-arm7hf.tar.gz
2) tar -xvzf geckodriver-v*
3) chmod +x geckodriver
4) sudo cp geckodriver /usr/local/bin/
Ensure that /usr/local/bin is in your shell PATH
Install InstaPy
1) sudo apt-get install python3-pip
2) python3 -m pip install --user instapy
3) sudo reboot (optional)
Finishing up the Firefox installation
1) sudo pip3 install future
2) sudo apt-get install xvfb
3) sudo pip3 install pyvirtualdisplay

Compilation failure "configure: error: udev support requested but libudev header not installed"

I did following on my ubuntu machine:
Git clone https://github.com/libusb/libusb.git
after extraction, ran ./autogen.sh script, this failed with following error:
checking libudev.h usability... no checking libudev.h presence... no
checking for libudev.h... no configure: error: udev support requested
but libudev header not installed
I also tried installing libudev using following command sudo apt-get install libudev-dev but it fails with following error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libudev1 udev
The following NEW packages will be installed:
libudev-dev
The following packages will be upgraded:
libudev1 udev
2 upgraded, 1 newly installed, 0 to remove and 83 not upgraded.
Need to get 1,197 kB of archives.
After this operation, 539 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Err:1 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 udev amd64 229-4ubuntu17
404 Not Found [IP: 91.189.88.162 80]
Err:2 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libudev1 amd64 229-4ubuntu17
404 Not Found [IP: 91.189.88.162 80]
Err:3 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libudev-dev amd64 229-4ubuntu17
404 Not Found [IP: 91.189.88.162 80]
Unable to correct missing packages.
E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/s/systemd/udev_229-4ubuntu17_amd64.deb 404 Not Found [IP: 91.189.88.162 80]
E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/s/systemd/libudev1_229-4ubuntu17_amd64.deb 404 Not Found [IP: 91.189.88.162 80]
E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/s/systemd/libudev-dev_229-4ubuntu17_amd64.deb 404 Not Found [IP: 91.189.88.162 80]
E: Aborting install.
Any help would be greatly appreciated. Thanks.
sudo apt install libudev-dev works on Ubuntu 18.04 LTS
I got this to working. First i installed libudev-dev the hardway.
1.wget http://kr.archive.ubuntu.com/ubuntu/pool/main/s/systemd/libudev-dev_204-5ubuntu20_amd64.deb and wget http://kr.archive.ubuntu.com/ubuntu/pool/main/s/systemd/libudev1_204-5ubuntu20_amd64.deb
Installed these packages using sudo dpkg -i <*.deb>
Now, ran ./autogen.sh under libusb folder.
Configuration completed successfully!

How to install apache2 in Ubuntu

I am trying to install apache2 in Ubuntu 12. I installed Ubuntu in Virtual Machine. I have problems. First, my system can not update or upgrade. When I type:
I receive a lot of errors like this:
Err http://security.ubuntu.com quantal-security/main Sources
404 Not Found [IP: 91.189.91.14 80]
At the final line, this is the result:
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/quantal-backports/multiverse/binary-i386/Packages 404 Not Found [IP: 91.189.91.13 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
Second, when I try to install apache2. I type:
sudo apt-get install apache2 apache2-doc apache2-utils
Again, it fails. The result:
e#ubuntu:/etc$ sudo apt-get install apache2 apache2-doc apache2-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package apache2
E: Unable to locate package apache2-doc
E: Unable to locate package apache2-utils
e#ubuntu:/etc$
Can you help me plz?
EDIT:
This command does not work either.
sudo apt-get update && sudo apt-get upgrade
I get:
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/quantal-backports/multiverse/binary-i386/Packages 404 Not Found [IP: 91.189.91.24 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
The problem is with the OS installation.
use sudo apt-get update && sudo apt-get upgrade. If ou cannot update. Then try to re-install the OS.
After a fresh install of your OS try sudo apt-get install apache2 apache2-doc apache2-utils

Install matplotlib with Plone 4.3.3 via buildout [duplicate]

When I try to upgrade my matplotlib using pip, it outputs:
Downloading/unpacking matplotlib from https://pypi.python.org/packages/source/m/matplotlib/matplotlib-1.4.0.tar.gz#md5=1daf7f2123d94745feac1a30b210940c
Downloading matplotlib-1.4.0.tar.gz (51.2MB): 51.2MB downloaded
Running setup.py (path:/tmp/pip_build_root/matplotlib/setup.py) egg_info for package matplotlib
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.4.0]
python: yes [2.7.6 (default, Mar 22 2014, 22:59:38) [GCC
4.8.2]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.8.2]
six: yes [using six version 1.7.3]
dateutil: yes [using dateutil version 2.2]
tornado: yes [using tornado version 4.0.1]
pyparsing: yes [using pyparsing version 2.0.2]
pycxx: yes [Couldn't import. Using local copy.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/matplotlib/setup.py", line 154, in <module>
result = package.check()
File "setupext.py", line 940, in check
if 'No such file or directory\ngrep:' in version:
TypeError: argument of type 'NoneType' is not iterable
Complete output from command python setup.py egg_info:
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.4.0]
python: yes [2.7.6 (default, Mar 22 2014, 22:59:38) [GCC
4.8.2]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.8.2]
six: yes [using six version 1.7.3]
dateutil: yes [using dateutil version 2.2]
tornado: yes [using tornado version 4.0.1]
pyparsing: yes [using pyparsing version 2.0.2]
pycxx: yes [Couldn't import. Using local copy.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/matplotlib/setup.py", line 154, in <module>
result = package.check()
File "setupext.py", line 940, in check
if 'No such file or directory\ngrep:' in version:
TypeError: argument of type 'NoneType' is not iterable
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Storing debug log for failure in /home/username/.pip/pip.log
In the tail of the log it says:
Exception information:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 325, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 697, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Why did it fail?
Many thanks!
This is a known bug that has been fixed (https://github.com/matplotlib/matplotlib/pull/3414) on master.
The bug is in the handling of searching for a freetype installation. If you install the Linux package freetype-dev, you will avoid this bug and be able to compile matplotlib.
sudo apt-get install libfreetype6-dev
On Ubuntu 14 server, you also need to install libxft-dev
sudo apt-get install libfreetype6-dev libxft-dev
I had the same issues trying to install matplotlib on Python 3 using pip3, and it seems that this problem is related to a bare-bones installation of Python 3, and doing a:
sudo apt-get build-dep matplotlib
followed by
sudo pip3 install matplotlib
is probably a better solution than selectively installing only the libraries related to matplotlib.
Since mac doesn't have apt-get you, on OSX you may need to do:
brew install freetype
then you can run:
pip install matplotlib
Found this page while looking answer for fedora 24.
RPM solution is:
dnf install freetype-devel
If you re running Ubuntu server 14.04 u should add this font dependency
sudo apt-get install libxft-dev
Source
I was trying too update directly using sudo pip but changes are not saved in last. So i first use update cmd in terminal:
sudo apt-get update
then i used sudo install:
sudo apt-get install libffi-dev
Finally its installed by doing this method.
For those on Fedora 25 hitting this thread, I needed these two packages to make it work:
sudo dnf install freetype-devel gcc-c++
This worked for me:
python -m pip install -U pip setuptools
python -m pip install matplotlib
For more details, follow : https://matplotlib.org/2.0.0/users/installing.html