Can't install pyproj module in Google Datalab Jupyter notebook - python

I'm trying to install pyproj within a Google Datalab Jupyter notebook as a required dependency for the basemap library. I've tried two methods, needless to say neither has worked.
Method 1: Cloning from git
!git clone https://github.com/jswhit/pyproj.git
Outputs:
Cloning into 'pyproj'...
remote: Counting objects: 2811, done.
remote: Total 2811 (delta 0), reused 0 (delta 0), pack-reused 2810
Receiving objects: 100% (2811/2811), 5.65 MiB | 1.55 MiB/s, done.
Resolving deltas: 100% (1951/1951), done.
Checking connectivity... done.
And install command:
!python ./pyproj/setup.py install
Outputs:
using bundled proj4..
unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
Traceback (most recent call last):
File "./pyproj/setup.py", line 86, in <module>
objects = cc.compile(['nad2bin.c', 'src/pj_malloc.c'])
File "/usr/lib/python2.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/usr/lib/python2.7/distutils/unixccompiler.py", line 122, in _compile
raise CompileError, msg
distutils.errors.CompileError: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Method 2: Using pip
!pip install pyproj
Outputs:
Collecting pyproj
Using cached pyproj-1.9.5.1.tar.gz
Complete output from command python setup.py egg_info:
unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
using bundled proj4..
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-FcWGXL/pyproj/setup.py", line 72, in <module>
objects = cc.compile(['nad2bin.c', 'src/pj_malloc.c'])
File "/usr/lib/python2.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/usr/lib/python2.7/distutils/unixccompiler.py", line 122, in _compile
raise CompileError, msg
distutils.errors.CompileError: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-FcWGXL/pyproj/
What method can be used to install pyproj from within a Datalab Jupyter notebook?

Looks like you need gcc for it to build. Do apt-get update && apt-get install -y gcc in a cell then try the pip install pyproj again.

Related

unable to install scikit-learn from git using jupyter notebook in my windows

i'm trying to import sklearn.metrics.multilabel_confusion_matrix, but since it is not in the normal package what I'm trying to do is install it using !pip install git+http://github.com/scikit-learn/scikit-learn.git in my windows using jupyter notebook. I used command prompt as well but the same problem occurred. but when I'm doing this an error is popping up which is shown bellow
it's saying something related to "Failed building wheel for scikit-learn
Could not install packages due to an EnvironmentError:"
have shown the complete dialogue below.
Please Help!!!
!pip install git+http://github.com/scikit-learn/scikit-learn.git
Collecting git+http://github.com/scikit-learn/scikit-learn.git
Cloning http://github.com/scikit-learn/scikit-learn.git to c:\users\intel\appdata\local\temp\pip-req-build-bg_zxcrm
Requirement already satisfied: numpy>=1.11.0 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn==0.22.dev0) (1.15.4)
Requirement already satisfied: scipy>=0.17.0 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn==0.22.dev0) (1.1.0)
Requirement already satisfied: joblib>=0.11 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn==0.22.dev0) (0.14.0)
Building wheels for collected packages: scikit-learn
Running setup.py bdist_wheel for scikit-learn: started
Running setup.py bdist_wheel for scikit-learn: finished with status 'error'
Complete output from command C:\PROGRAMDATA\ANACONDA3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\INTEL\\AppData\\Local\\Temp\\pip-req-build-bg_zxcrm\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\INTEL\AppData\Local\Temp\pip-wheel-vp_d4jnx --python-tag cp37:
Partial import of sklearn during the build process.
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
Traceback (most recent call last):
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 489, in _find_latest_available_vc_ver
return self.find_available_vc_vers()[-1]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\setup.py", line 290, in <module>
setup_package()
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\setup.py", line 286, in setup_package
setup(**metadata)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\distutils\core.py", line 135, in setup
config = configuration()
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\setup.py", line 174, in configuration
config.add_subpackage('sklearn')
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\distutils\misc_util.py", line 1037, in add_subpackage
caller_level = 2)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\distutils\misc_util.py", line 1006, in get_subpackage
caller_level = caller_level + 1)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\distutils\misc_util.py", line 943, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "sklearn\setup.py", line 81, in configuration
maybe_cythonize_extensions(top_path, config)
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\sklearn\_build_utils\__init__.py", line 43, in maybe_cythonize_extensions
with_openmp = check_openmp_support()
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\sklearn\_build_utils\openmp_helpers.py", line 84, in check_openmp_support
extra_postargs=openmp_flags)
File "C:\PROGRAMDATA\ANACONDA3\lib\distutils\_msvccompiler.py", line 345, in compile
self.initialize()
File "C:\PROGRAMDATA\ANACONDA3\lib\distutils\_msvccompiler.py", line 238, in initialize
vc_env = _get_vc_env(plat_spec)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 843, in __init__
self.si = SystemInfo(self.ri, vc_ver)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 485, in __init__
self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 492, in _find_latest_available_vc_ver
raise distutils.errors.DistutilsPlatformError(err)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
Running setup.py clean for scikit-learn
Failed to build scikit-learn
Installing collected packages: scikit-learn
Found existing installation: scikit-learn 0.20.1
Uninstalling scikit-learn-0.20.1:
Failed building wheel for scikit-learn
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\programdata\\anaconda3\\lib\\site-packages\\scikit_learn-0.20.1-py3.7.egg-info\\dependency_links.txt'
Consider using the `--user` option or check the permissions.
After getting a similar error I was able to install scikit-learn by following the instructions from the official site https://scikit-learn.org/stable/install.html.
Error caused by file path length limit on Windows
It can happen that pip fails to install packages when reaching the default path size limit of Windows if Python is installed in a nested location such as the AppData folder structure under the user home directory, for instance:
Collecting scikit-learn
...
Installing collected packages: scikit-learn
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\username\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\sklearn\\datasets\\tests\\data\\openml\\292\\api-v1-json-data-list-data_name-australian-limit-2-data_version-1-status-deactivated.json.gz'
In this case it is possible to lift that limit in the Windows registry by using the regedit tool:
Type “regedit” in the Windows start menu to launch regedit.
Go to the Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem key.
Edit the value of the LongPathsEnabled property of that key and set it to 1.
Reinstall scikit-learn (ignoring the previous broken installation):
pip install --exists-action=i scikit-learn

Python pip install fails with error

I have been trying to install yajl>=0.3.5 package and i get the following error. This happens for only this specific package and not for others i am currently using. The command is as follows.
pip install yajl>=0.3.5
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\ANURAG~1\AppData\Local\Temp\pip-build-epamw9qh\yajl\
Alternatively
I know there is a similar question asked and have tried all specified solutions in the mentioned question. Here are my findings.
1) I have successfully installed setuptools,upgraded them and also installed ez_setup. pip install yajl>=0.3.5 gives the same error as above even after this.
2) I have downloaded the source code of yajl>=0.3.5 and tried the following command.
cd yajl && python setup.py bdist_wheel
the error i get is as below.
Collecting yajl>=0.3.5
Using cached yajl-0.3.5.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ANURAG~1\AppData\Local\Temp\pycharm-packaging\yajl\setup.py",
line 64, in
subprocess.call(['git', 'submodule', 'update',])
File "C:\Program Files\Python\lib\subprocess.py", line 560, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Program Files\Python\lib\subprocess.py", line 950, in init
restore_signals, start_new_session)
File "C:\Program Files\Python\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\ANURAG~1\AppData\Local\Temp\pycharm-packaging\yajl\
PS: I am using windows 10.

Command "python setup.py egg_info" failed with error code 1

Extracting in C:\Users\hkpra\AppData\Local\Temp\tmp3esvodcb
Traceback (most recent call last):
File "c:\program files\python35\lib\site-packages\ez_setup.py", line 143, in use_setuptools
raise ImportError
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\hkpra\AppData\Local\Temp\pip-build-imphcwak\unroll\setup.py", line 2, in <module>
ez_setup.use_setuptools()
File "c:\program files\python35\lib\site-packages\ez_setup.py", line 145, in use_setuptools
return _do_download(version, download_base, to_dir, download_delay)
File "c:\program files\python35\lib\site-packages\ez_setup.py", line 125, in _do_download
_build_egg(egg, tarball, to_dir)
File "c:\program files\python35\lib\site-packages\ez_setup.py", line 99, in _build_egg
_extractall(tar)
File "c:\program files\python35\lib\site-packages\ez_setup.py", line 467, in _extractall
self.chown(tarinfo, dirpath)
TypeError: chown() missing 1 required positional argument: 'numeric_owner'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\hkpra\AppData\Local\Temp\pip-build-imphcwak\unroll\
These are the things you need to do to fix this error when installing python. Make sure to follow in accordance.
check if PIP and setuptools are installed.
upgrade PIP and setuptools.
install ez_setup.
Should you want step by step guidance on how to go about it, you can go here.
install python again, then successed
I also install by pip,lick
pip install locustio
or
sudo pip install locustio
but error occur
Collecting locustio
Using cached locustio-0.7.5.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
error: Invalid distribution name or version syntax: locustio-0.7.5
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/yw/15gswkd13v37xjqjy66rc8xc0000gn/T/pip-build-hFFjxs/locustio/
I try pip, pip3, and so on. Finally, I install python again and then it is ok.
for python2.7
sudo pip install python
for python3
sudo pip install python3

pip - unable to find vcvarsall.bat

From last week, I tried to solve this but couldn't fix this error. While, I tried to install, following error comes:
C:\Users\#######>pip install pyproj
Collecting pyproj
Using cached pyproj-1.9.5.1.tar.gz
Complete output from command python setup.py egg_info:
using bundled proj4..
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\H~1\AppData\Local\Temp\pip-build-e4o66o1z\pyproj\setup.py", line 72, in <module>
objects = cc.compile(['nad2bin.c', 'src/pj_malloc.c'])
File "C:\Users\######\Anaconda3\lib\distutils\_msvccompiler.py", line 317, in compile
self.initialize()
File "C:\Users\########\Anaconda3\lib\distutils\_msvccompiler.py", line 210, in initialize
vc_env = _get_vc_env(plat_spec)
File "C:\Users\#######\Anaconda3\lib\distutils\_msvccompiler.py", line 85, in _get_vc_env
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\H~1\AppData\Local\Temp\pip-build-e4o66o1z\pyproj\
I couldn't proceed ahead without fixing this error. I have installed Microsoft Visual C++.
Installing some Python packages under Windows can be troublesome. You can find a precompiled package at
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyproj
Just download the .whl file that suits your Python version then install it using
pip install <filename>.whl

Set up cassandra driver (python) in Docker

I used a docker file several months ago that (1) uses base ubuntu image, (2) installs miniconda python distribution, (3) installs some python libraries using miniconda, (4) runs following commands to set up cassandra-driver for python.
RUN pip install --upgrade pip
RUN pip install cassandra-driver
This worked perfectly six months ago. But now I'm getting this exception.
Step 13 : RUN pip install cassandra-driver
---> Running in ba9955650d7c
Collecting cassandra-driver
Downloading cassandra-driver-3.0.0.tar.gz (186kB)
Complete output from command python setup.py egg_info:
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Utility'
unable to execute 'gcc': No such file or directory
Unable to find pgen, not compiling formal grammar.
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-0XzsPv/cassandra-driver/setup.py", line 375, in <module>
run_setup(None)
File "/tmp/pip-build-0XzsPv/cassandra-driver/setup.py", line 373, in run_setup
**kw)
File "/miniconda/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 268, in __init__
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 312, in fetch_build_eggs
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 846, in resolve
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 1091, in best_match
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 1103, in obtain
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 379, in fetch_build_egg
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 639, in easy_install
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 669, in install_item
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 852, in install_eggs
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 1080, in build_and_install
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 1068, in run_setup
distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-0XzsPv/cassandra-driver
The command '/bin/sh -c pip install cassandra-driver' returned a non-zero code: 1
What might be going wrong? Is the installation package broken or I'm not doing it right?
The python cassandra-driver now uses Cython extensions by default since version 2.7.0, but there is an escape hatch for those who don't have easy access to the cython distribution or don't need it which might be a good option for you as well. The cython extensions do offer a boon to performance, but it might not be suitable for a lot of cases (especially where you are not doing high throughput).
From the install documentation:
By default, this package uses Cython to optimize core modules and build custom extensions. This is not a hard requirement, but is engaged by default to build extensions offering better performance than the pure Python implementation.
This build phase can be avoided using the build switch, or an environment variable:
python setup.py install --no-cython
-or-
pip install --install-option="--no-cython" <spec-or-path>
Alternatively, an environment variable can be used to switch this option regardless of context:
CASS_DRIVER_NO_CYTHON=1 <your script here>
In order to install cassandra-driver you need to compile some C source files however you don't have gcc inside your container:
unable to execute 'gcc': No such file or directory
Try to install gcc and python-dev packages before installing cassandra-driver:
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*

Categories