I get some error and problems when install "matplotlib"
Question:
I have get a virtual env on ‘/home/name/pyenv’ for python2.7.9;
Now I want to install ‘matplotlib’ for it;
then I activate this virtual env and install ‘matplotlib’ as below:
- by command “sudo apt-get install python-matplotlib”;
(if delete “sudo”, permission denied), it runs well and I find “matplotlib” is exactly installed, but it is for default python and not for virtual env(pyenv) ;
-
by command “pip install matplotlib”
I get error as below:
* The following required packages can not be built:
* freetype
Cleaning up…
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-tYCFkL/matplotlib
Exception information:
Traceback (most recent call last):
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/basecommand.py”, line 122, in main
status = self.run(options, args)
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/commands/install.py”, line 290, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/req.py”, line 1230, in prepare_files
req_to_install.run_egg_info()
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/req.py”, line 326, in run_egg_info
command_desc=’python setup.py egg_info’)
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/util.py”, line 716, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-tYCFkL/matplotlib
I want to install it by method 1, but i don;t know how to install it for virtual env.
Answers:
One possibility is to install matplotlib globally then create your virtualenv with the site packages, see here for someone with exactly the same problem, by using virtualenv --system-site-packages
you can then activate your virtualenv and add additional packages, or update them, within your virtualenv only.
I am reasonably sure that you can even uninstall globally installed packages within your virtualenv without impacting your global installation but suggest you pick a small package that you can easily reinstall to test this on early on.
when working in venv then try to used pip for installation for python packages ,sudo apt-get install normally using for root user of Linux. for your case you could try
pip install matplotlib==2.2.5
I have get a virtual env on ‘/home/name/pyenv’ for python2.7.9;
Now I want to install ‘matplotlib’ for it;
then I activate this virtual env and install ‘matplotlib’ as below:
- by command “sudo apt-get install python-matplotlib”;
(if delete “sudo”, permission denied), it runs well and I find “matplotlib” is exactly installed, but it is for default python and not for virtual env(pyenv) ; -
by command “pip install matplotlib”
I get error as below:
* The following required packages can not be built: * freetype
Cleaning up…
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-tYCFkL/matplotlib
Exception information:
Traceback (most recent call last):
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/basecommand.py”, line 122, in main
status = self.run(options, args)
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/commands/install.py”, line 290, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/req.py”, line 1230, in prepare_files
req_to_install.run_egg_info()
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/req.py”, line 326, in run_egg_info
command_desc=’python setup.py egg_info’)
File “/home/caofa/odoo-9.0/local/lib/python2.7/site-packages/pip/util.py”, line 716, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-tYCFkL/matplotlib
I want to install it by method 1, but i don;t know how to install it for virtual env.
One possibility is to install matplotlib globally then create your virtualenv with the site packages, see here for someone with exactly the same problem, by using virtualenv --system-site-packages
you can then activate your virtualenv and add additional packages, or update them, within your virtualenv only.
I am reasonably sure that you can even uninstall globally installed packages within your virtualenv without impacting your global installation but suggest you pick a small package that you can easily reinstall to test this on early on.
when working in venv then try to used pip for installation for python packages ,sudo apt-get install normally using for root user of Linux. for your case you could try
pip install matplotlib==2.2.5