Installing lxml with static dependencies - python

I'm trying to install lxml with static dependencies on OSX using the following command:
STATIC_DEPS=true pip install -U lxml --no-cache-dir
Running this throws a nice long error:
Collecting lxml
Downloading https://files.pythonhosted.org/packages/da/b5/d3e0d22649c63e92cb0902847da9ae155c1e801178ab5d272308f35f726e/lxml-4.3.4.tar.gz (2.5MB)
|████████████████████████████████| 2.5MB 2.2MB/s
ERROR: Complete output from command python setup.py egg_info:
ERROR: Checking for gcc...
Compiler error reporting is too harsh for ./configure (perhaps remove -Werror).
** ./configure aborting.
Building lxml version 4.3.4.
Latest version of zlib is 1.2.11
Downloading zlib into libs/zlib-1.2.11.tar.gz from https://zlib.net/zlib-1.2.11.tar.gz
Unpacking zlib-1.2.11.tar.gz into build/tmp
Latest version of libiconv is 1.16
Downloading libiconv into libs/libiconv-1.16.tar.gz from https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
Unpacking libiconv-1.16.tar.gz into build/tmp
Latest version of libxml2 is 2.9.9
Downloading libxml2 into libs/libxml2-2.9.9.tar.gz from http://xmlsoft.org/sources/libxml2-2.9.9.tar.gz
Unpacking libxml2-2.9.9.tar.gz into build/tmp
Latest version of libxslt is 1.1.33
Downloading libxslt into libs/libxslt-1.1.33.tar.gz from http://xmlsoft.org/sources/libxslt-1.1.33.tar.gz
Unpacking libxslt-1.1.33.tar.gz into build/tmp
Starting build in build/tmp/zlib-1.2.11
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/cy/ywx04ttn12n_xmgjf5s6sbzr0000gn/T/pip-install-27hg_iw0/lxml/setup.py", line 239, in <module>
**setup_extra_options()
File "/private/var/folders/cy/ywx04ttn12n_xmgjf5s6sbzr0000gn/T/pip-install-27hg_iw0/lxml/setup.py", line 150, in setup_extra_options
STATIC_CFLAGS, STATIC_BINARIES)
File "/private/var/folders/cy/ywx04ttn12n_xmgjf5s6sbzr0000gn/T/pip-install-27hg_iw0/lxml/setupinfo.py", line 81, in ext_modules
multicore=OPTION_MULTICORE)
File "/private/var/folders/cy/ywx04ttn12n_xmgjf5s6sbzr0000gn/T/pip-install-27hg_iw0/lxml/buildlibxml.py", line 412, in build_libxml2xslt
cmmi(zlib_configure_cmd, zlib_dir, multicore, **call_setup)
File "/private/var/folders/cy/ywx04ttn12n_xmgjf5s6sbzr0000gn/T/pip-install-27hg_iw0/lxml/buildlibxml.py", line 330, in cmmi
call_subprocess(configure_cmd, cwd=build_dir, **call_setup)
File "/private/var/folders/cy/ywx04ttn12n_xmgjf5s6sbzr0000gn/T/pip-install-27hg_iw0/lxml/buildlibxml.py", line 320, in call_subprocess
raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode))
Exception: Command "./configure --prefix=/private/var/folders/cy/ywx04ttn12n_xmgjf5s6sbzr0000gn/T/pip-install-27hg_iw0/lxml/build/tmp/libxml2" returned code 1
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/cy/ywx04ttn12n_xmgjf5s6sbzr0000gn/T/pip-install-27hg_iw0/lxml/
WARNING: You are using pip version 19.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Does anyone know how to resolve this snag? Any suggestions are welcome!

Related

installing pyinstaller on python 3.4.3

I'm trying to install pyinstaller 3.5 in python 3.4.3 but i get this error:
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\DTI~1.DES\AppData\Local\Temp\pip-install-_dyh3r_g\pefile\
The command i use is this:
pip install pyinstaller==3.5
I'm using the latest version that 3.4.3 can use of pip, setuptools and wheel.
pip 19.1.1
setuptools 43.0.0
wheel 0.33.6
I appreciate all the help.
this is the full log:
pip install pyinstaller=="3.5"
DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
Collecting pyinstaller==3.5
Using cached https://files.pythonhosted.org/packages/e2/c9/0b44b2ea87ba36395483a672fddd07e6a9cb2b8d3c4a28d7ae76c7e7e1e5/PyInstaller-3.5.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Collecting pywin32-ctypes>=0.2.0 (from pyinstaller==3.5)
Using cached https://files.pythonhosted.org/packages/9e/4b/3ab2720f1fa4b4bc924ef1932b842edf10007e4547ea8157b0b9fc78599a/pywin32_ctypes-0.2.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in c:\python34\lib\site-packages (from pyinstaller==3.5) (43.0.0)
Collecting altgraph (from pyinstaller==3.5)
Using cached https://files.pythonhosted.org/packages/ee/3d/bfca21174b162f6ce674953f1b7a640c1498357fa6184776029557c25399/altgraph-0.17-py2.py3-none-any.whl
Collecting pefile>=2017.8.1 (from pyinstaller==3.5)
Using cached https://files.pythonhosted.org/packages/f9/1e/fc4fac0169d16a98577809400bbcfac8ad1900fa792184327b360ea51fc6/pefile-2021.5.13.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\DTI~1.DES\AppData\Local\Temp\pip-install-3rgqa38b\pefile\setup.py", line 86, in <module>
long_description = "\n".join(_read_doc().split('\n')),
File "C:\Users\DTI~1.DES\AppData\Local\Temp\pip-install-3rgqa38b\pefile\setup.py", line 33, in _read_doc
tree = ast.parse(f.read())
File "c:\python34\lib\ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 3789
f'Export directory contains more than 10 repeated entries '
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\DTI~1.DES\AppData\Local\Temp\pip-install-3rgqa38b\pefile\
pefile (one of the PyInstaller dependencies) requires python >= 3.6.0
Try pip install pyinstaller This should work
or
If you wanted the specific version you can do that by
pip install pyinstaller == "3.5"

Installing flask-mysqldb gives "mysql_config not found"

I'm trying to install flask-mysql on ubuntu 18.04 and I keep getting this error:
(base) ether#ether:~/Documents/loginsystem$ pip install flask-mysqldb
Collecting flask-mysqldb
Using cached https://files.pythonhosted.org/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /home/ether/anaconda3/lib/python3.7/site-packages (from flask-mysqldb) (1.0.2)
Collecting mysqlclient (from flask-mysqldb)
Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-txlk8w2u/mysqlclient/
I tried to run sudo pip install and pip3 install flask-mysqldb but each time I received the same error as posted above.
What can I do to fix this?
The error message is pretty clear:
OSError: mysql_config not found
You need mysql_config. Install either libmariadbclient-dev or libmysqlclient-dev with apt.
Then try using pip again, but not with sudo.
Mixing system-level Python packages and pip-installed packages is a recipe for disaster. It looks like you already have a virtualenv for your project, so use that. Bonus points if you specify your dependencies in a requirements.txt file or Pipfile.

Geopandas installation error distutils.errors.CompileError

I have been using pip install geopandas for installing the library on my Mac (OS: Mojave v10.14). However, I have been unsuccessful to install so far.
Here is the error I get:
Collecting pyproj (from geopandas)
Downloading https://files.pythonhosted.org/packages/26/8c/1da0580f334718e04f8bbf74f0515a7fb8185ff96b2560ce080c11aa145b/pyproj-1.9.6.tar.gz (2.8MB)
100% |████████████████████████████████| 2.8MB 9.0MB/s
Complete output from command python setup.py egg_info:
using bundled proj4..
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-install-C35peF/pyproj/setup.py", line 86, in <module>
objects = cc.compile(['nad2bin.c', 'src/pj_malloc.c'])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/unixccompiler.py", line 125, in _compile
raise CompileError, msg
distutils.errors.CompileError: command 'cc' failed with exit status 1
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-C35peF/pyproj/
Any ideas why this might be happening and how can I fix this?
Pyproj PyPI is outdated. You can either install GeoPandas via Conda or follow steps described in this GH issue https://github.com/geopandas/geopandas/issues/793 and install pyproj beforehand from Github via
pip install git+https://github.com/jswhit/pyproj.git#egg=pyproj
and then go for pip install geopandas.

i can't install mysqlclient and pillow in python

i want to install mysqlclient but it returns me
(venv)amir#amg76:~/Documents/Computer/Python/Django/vira/virasciencecom$ pip3 install mysqlclient==1.3.7
Collecting mysqlclient==1.3.7
Using cached mysqlclient-1.3.7.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-c5i8m5ok/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-c5i8m5ok/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-c5i8m5ok/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-c5i8m5ok/mysqlclient/
the same thing happen when i try to install pillow and i use python 3.6 and ubuntu 17.10
can any body help me?
You need to install libmysqlclient-dev or libmariaclient-dev from your distro package repository, depending whether you're using mysql or mariadb respectively.

Real world working solution to anaconda environments and pip

What is the real world proven working method to conda switch to a Python 2.7 environment and install mechanize using pip?
Here's a new brand new stock Anaconda install which I just tested and get:
C:\Program Files\Anaconda3\Scripts>activate py27
(py27) C:\Program Files\Anaconda3\Scripts>pip install mechanize
Collecting mechanize
Downloading mechanize-0.3.6.tar.gz (201kB)
100% |████████████████████████████████| 204kB 1.7MB/s
Complete output from command python setup.py egg_info:
mechanize only works on python 2.x
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Temp\pip-build-cmll3
thk\mechanize\
(py27) C:\Program Files\Anaconda3\Scripts>pip install --upgrade setuptools
Collecting setuptools
Downloading setuptools-36.6.0-py2.py3-none-any.whl (481kB)
100% |████████████████████████████████| 481kB 428kB/s
Installing collected packages: setuptools
Found existing installation: setuptools 27.2.0
Uninstalling setuptools-27.2.0:
Successfully uninstalled setuptools-27.2.0
Successfully installed setuptools-36.6.0
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\Scripts\pip-script.py", line 5, in <module>
sys.exit(pip.main())
File "C:\Program Files\Anaconda3\lib\site-packages\pip\__init__.py", line 249, in ma
in
return command.main(cmd_args)
File "C:\Program Files\Anaconda3\lib\site-packages\pip\basecommand.py", line 252, in
main
pip_version_check(session)
File "C:\Program Files\Anaconda3\lib\site-packages\pip\utils\outdated.py", line 102,
in pip_version_check
installed_version = get_installed_version("pip")
File "C:\Program Files\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 838,
in get_installed_version
working_set = pkg_resources.WorkingSet()
File "C:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init_
_.py", line 644, in __init__
self.add_entry(entry)
File "C:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init_
_.py", line 700, in add_entry
for dist in find_distributions(entry, True):
File "C:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init_
_.py", line 1949, in find_eggs_in_zip
if metadata.has_metadata('PKG-INFO'):
File "C:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init_
_.py", line 1463, in has_metadata
return self.egg_info and self._has(self._fn(self.egg_info, name))
File "C:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init_
_.py", line 1823, in _has
return zip_path in self.zipinfo or zip_path in self._index()
File "C:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init_
_.py", line 1703, in zipinfo
return self._zip_manifests.load(self.loader.archive)
File "C:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init_
_.py", line 1643, in load
mtime = os.stat(path).st_mtime
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Progra
m Files\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg'
(py27) C:\Program Files\Anaconda3\Scripts>pip install ez_setup
Collecting ez_setup
Downloading ez_setup-0.9.tar.gz
Building wheels for collected packages: ez-setup
Running setup.py bdist_wheel for ez-setup ... done
Stored in directory: C:\Users\Admin1\AppData\Local\pip\Cache\wheels\53\d6\8b\a2270e6
6cf5f68c038fffcc8b871de0c4326550fb187906bab
Successfully built ez-setup
Installing collected packages: ez-setup
Successfully installed ez-setup-0.9
(py27) C:\Program Files\Anaconda3\Scripts>pip install --upgrade setuptools
Requirement already up-to-date: setuptools in c:\program files\anaconda3\lib\site-pack
ages
(py27) C:\Program Files\Anaconda3\Scripts>pip install --upgrade setuptools --force
Collecting setuptools
Using cached setuptools-36.6.0-py2.py3-none-any.whl
Installing collected packages: setuptools
Found existing installation: setuptools 36.6.0
Uninstalling setuptools-36.6.0:
Successfully uninstalled setuptools-36.6.0
Successfully installed setuptools-36.6.0
(py27) C:\Program Files\Anaconda3\Scripts>pip install mechanize
Collecting mechanize
Using cached mechanize-0.3.6.tar.gz
Complete output from command python setup.py egg_info:
mechanize only works on python 2.x
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Temp\pip-build-qo4zx
99o\mechanize\
(py27) C:\Program Files\Anaconda3\Scripts>easy_install -U setuptools
Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Downloading https://pypi.python.org/packages/45/29/8814bf414e7cd1031e1a3c8a4169218376e
284ea2553cc0822a6ea1c2d78/setuptools-36.6.0.zip#md5=74663b15117d9a2cc5295d76011e6fd1
Best match: setuptools 36.6.0
Processing setuptools-36.6.0.zip
Writing C:\Temp\easy_install-wyi8iiw7\setuptools-36.6.0\setup.cfg
Running setuptools-36.6.0\setup.py -q bdist_egg --dist-dir C:\Temp\easy_install-wyi8ii
w7\setuptools-36.6.0\egg-dist-tmp-eq7ol_dl
warning: no files found matching '*' under directory 'setuptools\_vendor'
Copying setuptools-36.6.0-py3.6.egg to c:\program files\anaconda3\lib\site-packages
Adding setuptools 36.6.0 to easy-install.pth file
Installing easy_install-script.py script to c:\program files\anaconda3\Scripts
Installing easy_install.exe script to c:\program files\anaconda3\Scripts
error: [WinError 5] Access is denied: 'c:\\program files\\anaconda3\\Scripts\\easy_ins
tall.exe'
(py27) C:\Program Files\Anaconda3\Scripts>pip install mechanize
Collecting mechanize
Using cached mechanize-0.3.6.tar.gz
Complete output from command python setup.py egg_info:
mechanize only works on python 2.x
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Temp\pip-build-ui1ll
y8p\mechanize\
(py27) C:\Program Files\Anaconda3\Scripts>pip install --upgrade setuptools --force
(py27) C:\Program Files\Anaconda3\Scripts>
(py27) C:\Program Files\Anaconda3\Scripts>
(py27) C:\Program Files\Anaconda3\Scripts>
(py27) C:\Program Files\Anaconda3\Scripts>python -m pip install --upgrade pip
Requirement already up-to-date: pip in c:\program files\anaconda3\envs\py27\lib\site-p
ackages
(py27) C:\Program Files\Anaconda3\Scripts>pip install mechanize --force
Collecting mechanize
Using cached mechanize-0.3.6.tar.gz
Complete output from command python setup.py egg_info:
mechanize only works on python 2.x
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Temp\pip-build-rsxl3
v5_\mechanize\
The main advantage of anaconda is that they've taken the time to compile packages (not just Python ones) and ensure they're compatible with each other, so that everything should "just work' for the user. This is especially useful on Windows, where compiling some Python packages may be difficult (and not everything has a wheel available on PyPI).
Such packages are available to install via conda install <foo>. Whilst you can still use pip install <foo> (and indeed will need to do so for any packages not available through anaconda's package manager), you should use the conda install where packages are available - otherwise you're not getting the benefit that anaconda intends to provide.
So (as per anaconda's docs for mechanize) you want:
conda install -c conda-forge mechanize
(You explicitly requested no attempts to convince you to use a different approach - I'm taking that to mean that you want to use anaconda and python27, rather than to definitely use pip. Obviously this is no help if pip is a must for you! I believe the "real world solution" that you're after is to use conda install rather than pip install wherever possible when using anaconda - see the answers to this question for an explanation of the differences between pip and conda)

Categories

Resources