ModuleNotFoundError: No module named 'Cython' when installing pyarrow - python

I am trying to install packages from requirements.txt in a virtualenv. However, when pip comes to installing pyarrow, it fails with the following:
Collecting pyarrow==0.9.0 (from -r requirements.txt (line 41))
Using cached https://files.pythonhosted.org/packages/be/2d/11751c477e4e7f4bb07ac7584aafabe0d0608c170e4bff67246d695ebdbe/pyarrow-0.9.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-dgdvn2c1/pyarrow/setup.py", line 29, in <module>
from Cython.Distutils import build_ext as _build_ext
ModuleNotFoundError: No module named 'Cython'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-dgdvn2c1/pyarrow/
I am using Python 3.6.3 and Pip 18.0
What I tried:
Most of the SO answers ask to check if python and pip refer to the venv python and I am sure it does.
$ which python
/Users/ME/repos/myproject/venv/bin/python
(venv)
I also tried installing cython via pip and even then installation fails albeit with a different error.
How do I solve this?
Edit:
Stacktrace after installing Cython:
Collecting pyarrow==0.9.0 (from -r requirements.txt (line 41))
Using cached https://files.pythonhosted.org/packages/be/2d/11751c477e4e7f4bb07ac7584aafabe0d0608c170e4bff67246d695ebdbe/pyarrow-0.9.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/setup.py", line 508, in <module>
url="https://arrow.apache.org/"
File "/Users/ME/Work/myproject/venv/lib/python3.6/site-packages/setuptools/__init__.py", line 131, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/Users/ME/Work/myproject/venv/lib/python3.6/site-packages/setuptools/dist.py", line 370, in __init__
k: v for k, v in attrs.items()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 281, in __init__
self.finalize_options()
File "/Users/ME/Work/myproject/venv/lib/python3.6/site-packages/setuptools/dist.py", line 529, in finalize_options
ep.load()(self, ep.name, value)
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/.eggs/setuptools_scm-3.0.5-py3.6.egg/setuptools_scm/integration.py", line 23, in version_keyword
dist.metadata.version = get_version(**value)
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/.eggs/setuptools_scm-3.0.5-py3.6.egg/setuptools_scm/__init__.py", line 135, in get_version
parsed_version = _do_parse(config)
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/.eggs/setuptools_scm-3.0.5-py3.6.egg/setuptools_scm/__init__.py", line 77, in _do_parse
parse_result = _call_entrypoint_fn(config, config.parse)
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/.eggs/setuptools_scm-3.0.5-py3.6.egg/setuptools_scm/__init__.py", line 40, in _call_entrypoint_fn
return fn(config.absolute_root)
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/setup.py", line 462, in parse_version
return version_from_scm(root)
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/.eggs/setuptools_scm-3.0.5-py3.6.egg/setuptools_scm/__init__.py", line 28, in version_from_scm
return _version_from_entrypoint(root, "setuptools_scm.parse_scm")
File "/private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/.eggs/setuptools_scm-3.0.5-py3.6.egg/setuptools_scm/__init__.py", line 44, in _version_from_entrypoint
for ep in iter_matching_entrypoints(config.absolute_root, entrypoint):
AttributeError: 'str' object has no attribute 'absolute_root'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/tj/nzhk3hh12074tfyhtgpkw0zm0000gn/T/pip-install-98s3ff2r/pyarrow/

This is a known issue (#2163) with pyarrow that has been closed without a fix.
It's worth noting that there is no pyarrow 0.9.0 wheel available for MacOS in pypi. It was made available in a subsequent 0.9.0.post1 release.
The following should work with Python 3.6 on MacOS:
pip install pyarrow==0.9.0.post1

Related

Macbook m1 unable to install python-binance

I'm trying to install python-binance libs on my MacBook M1 (learning python and crypto)... had same kind of issues with TA-Lib but fixed that with brew install
I keep getting
renaatvandewiele#Renaats-MBP Pythontrade % sudo -H python3.9 -m pip install python-binance Password: Collecting python-binance Using cached python_binance-0.7.9-py2.py3-none-any.whl (36 kB) Requirement already satisfied: requests in /opt/homebrew/lib/python3.9/site-packages (from python-binance) (2.25.1) Collecting service-identity Using cached service_identity-18.1.0-py2.py3-none-any.whl (11 kB) Collecting cryptography Using cached cryptography-3.4.6.tar.gz (546 kB) Installing build dependencies ... done Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/python#3.9/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp9xr5jjee
cwd: /private/tmp/pip-install-nvlbt5or/cryptography_372649a7a69d4e9ab469653b0c8c59e7
Complete output (58 lines):
=============================DEBUG ASSISTANCE=============================
If you are seeing a compilation error please try the following steps to
successfully install cryptography:
1) Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
2) Read https://cryptography.io/en/latest/installation.html for specific
instructions for your platform.
3) Check our frequently asked questions for more information:
https://cryptography.io/en/latest/faq.html
4) Ensure you have a recent Rust toolchain installed:
https://cryptography.io/en/latest/installation.html#rust
5) If you are experiencing issues with Rust for *this release only* you may
set the environment variable `CRYPTOGRAPHY_DONT_BUILD_RUST=1`.
=============================DEBUG ASSISTANCE=============================
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
main()
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
self.run_setup()
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 145, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 71, in <module>
setup(
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 432, in __init__
_Distribution.__init__(self, {
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 292, in __init__
self.finalize_options()
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 708, in finalize_options
ep(self)
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 715, in _finalize_setup_keywords
ep.load()(self, ep.name, value)
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 219, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "src/_cffi_src/build_openssl.py", line 76, in <module>
ffi = build_ffi_for_binding(
File "src/_cffi_src/utils.py", line 53, in build_ffi_for_binding
ffi = build_ffi(
File "src/_cffi_src/utils.py", line 73, in build_ffi
ffi = FFI()
File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/cffi/api.py", line 48, in __init__
import _cffi_backend as backend
ImportError: dlopen(/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 2): no suitable image found. Did find:
/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture
/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/fa/2d/2154d8cb773064570f48ec0b60258a4522490fcb115a6c7c9423482ca993/cryptography-3.4.6.tar.gz#sha256=2d32223e5b0ee02943f32b19245b61a62db83a882f0e76cc564e1cec60d48f87 (from https://pypi.org/simple/cryptography/) (requires-python:>=3.6). Command errored out with exit status 1: /opt/homebrew/opt/python#3.9/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp9xr5jjee Check the logs for full command output.
Using cached cryptography-3.4.5.tar.gz (546 kB)
cryptography does not currently ship an arm64 macOS wheel (due to no CI being available). To install it successfully you will need to follow the instructions here: https://cryptography.io/en/latest/installation.html#building-cryptography-on-macos

Python Error when installing ruamel.yaml package with pip

I am receiving an error when I want to install the ruamel.yaml package
Here is the command:
python --version;pip --version;pip install ruamel.yaml
And the output:
Python 2.7.10
pip 10.0.0 from /Library/Python/2.7/site-packages/pip (python 2.7)
Collecting ruamel.yaml
Downloading https://files.pythonhosted.org/packages/c1/ad/9557a78f1b61951623c56225e05dacdd81f80519f13fc39a926a5793edfa/ruamel.yaml-0.15.37.tar.gz (280kB)
100% |████████████████████████████████| 286kB 4.4MB/s
Complete output from command python setup.py egg_info:
sys.argv ['-c', 'egg_info', '--egg-base', 'pip-egg-info']
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/8j/69k5q3yn4y51g5nt2g7g9b9n24s68p/T/pip-install-htyM8C/ruamel.yaml/setup.py", line 917, in <module>
main()
File "/private/var/folders/8j/69k5q3yn4y51g5nt2g7g9b9n24s68p/T/pip-install-htyM8C/ruamel.yaml/setup.py", line 905, in main
setup(**kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 272, in __init__
_Distribution.__init__(self,attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 326, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2385, in require
reqs = self.dist.requires(self.extras)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2617, in requires
dm = self._dep_map
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2606, in _dep_map
if invalid_marker(marker):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1424, in is_invalid_marker
cls.evaluate_marker(text)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1549, in _markerlib_evaluate
env = cls._translate_metadata2(_markerlib.default_environment())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1537, in _translate_metadata2
for key, value in env
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1536, in <genexpr>
(key.replace('.', '_'), value)
ValueError: too many values to unpack
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/8j/69k5q3yn4y51g5nt2g7g9b9n24s68p/T/pip-install-htyM8C/ruamel.yaml/
To give a bit of a background. I installed python3 with brew and I uninstalled it thereafter.
Now I cannot install ruamel.yaml
Has anybody had the same issue?
How did you solve it?
You should do a pip list and check your version of setuptools should be (28.8.0). If you have an older version, upgrade with pip install -U setuptools.
You should consider upgrading from 2.7.10 to a newer version of Python 2 (currently 2.7.14), which should solve your SSL problems. Make sure you don't overwrite the system python if you are running on Linux.
I was able to resolve this by downgrading the python version from 3.10.+ to 3.9.+

Import Error: module object has no attribute 'check_specifier' error

On my Buildbot virtual environments, I have been facing a weird error with installing tornado which is a dependency of sphinx-autobuild==0.6.0.
>>> pip install --upgrade sphinx-autobuild==0.6.0
Collecting tornado>=3.2 (from sphinx-autobuild==0.6.0->-r towerportal/requirements.txt (line 76))
Using cached https://files.pythonhosted.org/packages/cf/d1/3be271ae5eba9fb59df63c9891fdc7d8044b999e8ac145994cdbfd2ae66a/tornado-5.0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-Bpw6k7/tornado/setup.py", line 192, in <module>
**kwargs
File "/spare/local/buildslave/.pyenv/versions/2.7.12/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/spare/local/buildslave/slaveA/demoA/build/virt/lib/python2.7/site-packages/setuptools/dist.py", line 269, in __init__
_Distribution.__init__(self,attrs)
File "/spare/local/buildslave/.pyenv/versions/2.7.12/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/spare/local/buildslave/slaveA/demoA/build/virt/lib/python2.7/site-packages/setuptools/dist.py", line 325, in finalize_options
ep.load()(self, ep.name, value)
File "/spare/local/buildslave/slaveA/demoA/build/virt/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2310, in load
return self.resolve()
File "/spare/local/buildslave/slaveA/demoA/build/virt/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2320, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'check_specifier'
My setuptools version is 39.0.1. Fortunately reinstalling setuptools using pip install -I setuptools tends to fix the problem. But my real question is what does reinstalling the same package with same version name really changes such that it resolves the problem? Has setuptools been erroneously released with different codebase for same version?

"python setup.py egg_info" error for pyproj package but not others

I've been trying to install the pyproj python package (I want to use the stateplane part specifically). Long story short.. I have a csv of lat, long, and a variable value and wanted to extract data for each state. I was going to use the
stateplane.identify(-80.1, 36.2, fmt='short')
feature to identify the state. I have verified that I have python 3.6.3 and pip 9.0.1. Doing pip install worked for the libusb package, but I'm getting an error when I do
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 "c:\python36-32\lib\site-packages\setuptools\msvc.py", line 490, 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\smshp\AppData\Local\Temp\pip-build-_bzisu0o\pyproj\setup.py
", line 72, in <module>
objects = cc.compile(['nad2bin.c', 'src/pj_malloc.c'])
File "c:\python36-32\lib\distutils\_msvccompiler.py", line 345, in compile
self.initialize()
File "c:\python36-32\lib\distutils\_msvccompiler.py", line 238, in initial
ize
vc_env = _get_vc_env(plat_spec)
File "c:\python36-32\lib\site-packages\setuptools\msvc.py", line 185, in m
svc14_get_vc_env
return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
File "c:\python36-32\lib\site-packages\setuptools\msvc.py", line 844, in _
_init__
self.si = SystemInfo(self.ri, vc_ver)
File "c:\python36-32\lib\site-packages\setuptools\msvc.py", line 486, in _
_init__
self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
File "c:\python36-32\lib\site-packages\setuptools\msvc.py", line 493, in _
find_latest_available_vc_ver
raise distutils.errors.DistutilsPlatformError(err)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is requir
ed. Get it with "Microsoft Visual C++ Build Tools":
http://landinghub.visualstud
io.com/visual-cpp-build-tools
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\smshp\Ap
pData\Local\Temp\pip-build-_bzisu0o\pyproj\
I have followed the troubleshooting tips from this post word to no avail.
Alternatively, if I downloaded the repo and did
python setup.py install
would I download the .whl or tar.gz file and would I download it to the python36-32 directory or where?
Thanks!

ImportErrors with Python setuptools.command.sdist

I'm trying to install Newspaper, which installs a whole bunch of dependencies using pip. During the installation of a lot of its dependencies, this error is getting raised:
ImportError: <module 'setuptools.command.sdist' from '/usr/local/lib/python2.6/dist-packages/setuptools-10.0.1-py2.6.egg/setuptools/command/sdist.pyc'> has no '_default_revctrl' attribute
Installing without pip works fine, but is quite tedious due to the number of dependencies Newspaper has. Can anyone give me a hand?
Here's the full traceback for one instance of the error:
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/Pillow.egg-info
writing pip-egg-info/Pillow.egg-info/PKG-INFO
writing top-level names to pip-egg-info/Pillow.egg-info/top_level.txt
writing dependency_links to pip-egg-info/Pillow.egg-info/dependency_links.txt
writing pip-egg-info/Pillow.egg-info/PKG-INFO
writing top-level names to pip-egg-info/Pillow.egg-info/top_level.txt
writing dependency_links to pip-egg-info/Pillow.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/Pillow.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-auItlo/Pillow/setup.py", line 757, in <module>
zip_safe=True,
File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "<string>", line 15, in replacement_run
File "/usr/local/lib/python2.6/dist-packages/setuptools-10.0.1-py2.6.egg/setuptools/command/egg_info.py", line 206, in find_sources
mm.run()
File "/usr/local/lib/python2.6/dist-packages/setuptools-10.0.1-py2.6.egg/setuptools/command/egg_info.py", line 290, in run
self.add_defaults()
File "/usr/local/lib/python2.6/dist-packages/setuptools-10.0.1-py2.6.egg/setuptools/command/egg_info.py", line 322, in add_defaults
rcfiles = list(walk_revctrl())
File "/usr/local/lib/python2.6/dist-packages/setuptools-10.0.1-py2.6.egg/setuptools/command/sdist.py", line 18, in walk_revctrl
for item in ep.load()(dirname):
File "/usr/local/lib/python2.6/dist-packages/setuptools-10.0.1-py2.6.egg/pkg_resources/__init__.py", line 2265, in load
raise ImportError("%r has no %r attribute" % (entry, attr))
ImportError: <module 'setuptools.command.sdist' from '/usr/local/lib/python2.6/dist-packages/setuptools-10.0.1-py2.6.egg/setuptools/command/sdist.pyc'> has no '_default_revctrl' attribute
This could also be caused by a change in setuptools released today:
https://bitbucket.org/pypa/setuptools/issue/320/cannot-upgrade-to-1001
running easy_install solved it for me:
easy_install --upgrade setuptools
Upgrading setuptools with pip can solve this:
sudo pip install --upgrade setuptools

Categories

Resources