python3 -m build gives ModuleNotFoundError: No module named 'pathlib2' - python

I am trying to build a Python package, but it gives the following error.
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
* Getting dependencies for sdist...
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 351, in <module>
main()
File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 333, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 285, in get_requires_for_build_sdist
return hook(config_settings)
File "/tmp/build-env-eyqolcf7/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_sdist
return self._get_build_requires(config_settings, requirements=[])
File "/tmp/build-env-eyqolcf7/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "/tmp/build-env-eyqolcf7/lib/python3.10/site-packages/setuptools/build_meta.py", line 482, in run_setup
super(_BuildMetaLegacyBackend,
File "/tmp/build-env-eyqolcf7/lib/python3.10/site-packages/setuptools/build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 5, in <module>
ModuleNotFoundError: No module named 'pathlib2'
ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist
I have already installed pathlib2. What is the solution?

I have successfully build this in Python3.10. pip3.10 freeze gave me this output
build==0.8.0
packaging==21.3
pep517==0.13.0
pyparsing==3.0.9
tomli==2.0.1

As per the official documentation of the build package, it does not have a stable compatibility
https://pypa-build.readthedocs.io/en/latest/installation.html#compatibility
You can try switching to an older version of python (3.9 recommended) and try again,
ideally, that should solve the error since in traceback, the error seems to originate from setuptools ( which will be automatically reverted back to an older version with a older python version )
NOTE: You will also need to reinstall build in the new python version
Let me know if you face any issues with it.

Related

Conda skeleton pypi fails with pmdarima -- AttributeError numpy disutils

I'm trying to install pmdarima package in a conda env as it requires statsmodels <0.12 and I would also like to use statmodels latest release for this project. My understanding is limited, but I first tried
conda skeleton pypi pmdarima
This failed with the same AttributeError related to numpy disutils described below.
Similarly to the questioner in this question: Conda skeleton pypi: ModuleNotFoundError: No module named 'numpy' I was unable to get this to work either.
conda install -n _build numpy
I then tried the advice laid out in the above-linked SO question and ran:
conda skeleton pypi --extra-specs numpy pmdarima
This results in pretty long output but the key piece as far as I can tell is:
Applying patch: '/var/folders/7f/8d7rz34522gcq4z774n9v91r0000gn/T/tmp8tv1gdnxconda_skeleton_pmdarima-1.7.1.tar.gz/pypi-distutils.patch'
patching file core.py
Hunk #1 succeeded at 168 with fuzz 2 (offset 1 line).
Partial import of pmdarima during the build process.
Requirements: ['joblib>=0.11', 'Cython>=0.29,<0.29.18', 'numpy>=1.17.3', 'pandas>=0.19', 'scikit-learn>=0.22', 'scipy>=1.3.2', 'statsmodels>=0.11,<0.12', 'urllib3', 'setuptools<50.0.0']
Setting up with numpy.distutils.core
Traceback (most recent call last):
File "setup.py", line 324, in <module>
do_setup()
File "setup.py", line 320, in do_setup
setup(**metadata)
File "/opt/anaconda3/conda-bld/skeleton_1599410605346/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/lib/python3.7/site-packages/numpy/distutils/core.py", line 130, in setup
if dist.help or not _command_line_ok():
AttributeError: 'NoneType' object has no attribute 'help'
$PYTHONPATH = /var/folders/7f/8d7rz34522gcq4z774n9v91r0000gn/T/tmp8tv1gdnxconda_skeleton_pmdarima-1.7.1.tar.gz/pmdarima-1.7.1
Leaving build/test directories:
Work:
/opt/anaconda3/conda-bld/skeleton_1599410605346/work
Test:
/opt/anaconda3/conda-bld/skeleton_1599410605346/test_tmp
Leaving build/test environments:
Test:
source activate /opt/anaconda3/conda-bld/skeleton_1599410605346/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place
Build:
source activate /opt/anaconda3/conda-bld/skeleton_1599410605346/_build_env
Error: command failed: /opt/anaconda3/conda-bld/skeleton_1599410605346/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/bin/python setup.py install
Any ideas? Thank you so much in advance, very much appreciated!
Not sure what the proper resolution is for the NumPy-based build, but the setup.py does check for an sdist argument, which branches to use setuptools for the build instead of numpy. Hence, the following seems to avoid the code causing the issue:
conda skeleton pypi --setup-options sdist pmdarima
I suspect the downside to this workaround is that there is no Cython compilation done, but not totally sure.
You may want to file an issue on the pmdarima GitHub to see if any of the devs have ideas. Otherwise, it might just be more efficient to pip install the package in the environment you want it (as long as that environment is not base).
#merv thank you for your help! Interestingly, this works for the skeleton, but fails when running conda-build with the following (truncated until the errors) output:
0 location(s) to search for versions of sdist:
Given no hashes to check 0 links for project 'sdist': discarding no candidates
ERROR: Could not find a version that satisfies the requirement sdist (from versions: none)
ERROR: No matching distribution found for sdist
Exception information:
Traceback (most recent call last):
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
status = self.run(options, args)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
return func(self, options, args)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 325, in run
reqs, check_supported_wheels=not options.target_dir
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 339, in _get_abstract_dist_for
self._populate_link(req)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 305, in _populate_link
req.link = self._find_requirement_link(req)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 270, in _find_requirement_link
best_candidate = self.finder.find_requirement(req, upgrade)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 928, in find_requirement
req)
pip._internal.exceptions.DistributionNotFound: No matching distribution found for sdist
Removed build tracker: '/private/tmp/pip-req-tracker-umxriyi2'
Traceback (most recent call last):
File "/opt/anaconda3/bin/conda-build", line 11, in <module>
sys.exit(main())
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 474, in main
execute(sys.argv[1:])
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 465, in execute
verify=args.verify, variants=args.variants)
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/api.py", line 210, in build
notest=notest, variants=variants)
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/build.py", line 3036, in build_tree
notest=notest,
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/build.py", line 2155, in build
cwd=src_dir, stats=build_stats)
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/utils.py", line 407, in check_call_env
return _func_defaulting_env_to_os_environ('call', *popenargs, **kwargs)
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/utils.py", line 387, in _func_defaulting_env_to_os_environ
raise subprocess.CalledProcessError(proc.returncode, _args)
subprocess.CalledProcessError: Command '['/bin/bash', '-o', 'errexit', '/opt/anaconda3/conda-bld/pmdarima_1599500058832/work/conda_build.sh']' returned non-zero exit status 1.
I'll confess we're well above my head at this point, (do I need to edit the meta.yaml file somehow? Is that crazy?) but will try opening an issue as you suggested, once again really appreciate it.

Runtimeerror (python 3.5 or later is required) when I try to install any library

I am trying to install some libraries to use on my python 3.4, but every time that I run pip install ("name of library") , it returns the following error:
Collecting pyautogui
Using cached https://files.pythonhosted.org/packages/35/71/a7d328fe19667777fb0c371ca346c89d1b380f7778fa1ba65aca1090478c/PyAutoGUI-0.9.49.tar.gz
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 339, in run
requirement_set.prepare_files(finder)
File "C:\Python34\lib\site-packages\pip\req\req_set.py", line 385, in prepare_files
req_to_install.run_egg_info()
File "C:\Python34\lib\site-packages\pip\req\req_install.py", line 310, in run_egg_info
self.setup_py, self.name,
File "C:\Python34\lib\site-packages\pip\req\req_install.py", line 281, in setup_py
import setuptools # noqa
File "C:\Python34\lib\site-packages\setuptools\__init__.py", line 17, in <module>
import setuptools.version
File "C:\Python34\lib\site-packages\setuptools\version.py", line 1, in <module>
import pkg_resources
File "C:\Python34\lib\site-packages\pkg_resources\__init__.py", line 93, in <module>
raise RuntimeError("Python 3.5 or later is required")
RuntimeError: Python 3.5 or later is required
You are seeing this because pip 19.2 has dropped support for Python 3.4.
Good news: The get-pip.py script has been updated to include a 3.4-specific option. You can use the following command to request pip 19.1, the last version of pip that supports Python 3.4:
python get-pip.py pip==19.1
The best option here is (if you can) to upgrade to a supported python version, see https://endoflife.date/python for the list of the currently supported python versions

Unable to install any packages using easy_install [duplicate]

This question already has answers here:
Unable to install Flask-Mail
(2 answers)
Closed 6 years ago.
Whenever I run the command pip install Django I get the following error trace which means there is some version conflict. I tried uninstalling and then installing the same package, but it's throwing up the same error.
Downloading/unpacking bcrypt (from Django)
Downloading bcrypt-2.0.0.tar.gz
Running setup.py (path:/tmp/pip_build_root/bcrypt/setup.py) egg_info for package bcrypt
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/bcrypt/setup.py", line 226, in <module>
**keywords_with_side_effects(sys.argv)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 225, in __init__
_Distribution.__init__(self,attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 257, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2029, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 592, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (certifi 2016.2.28 (/usr/local/lib/python2.7/dist-packages), Requirement.parse('certifi==2015.11.20'))
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/bcrypt/setup.py", line 226, in <module>
**keywords_with_side_effects(sys.argv)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 225, in __init__
_Distribution.__init__(self,attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 257, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2029, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 592, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (certifi 2016.2.28 (/usr/local/lib/python2.7/dist-packages), Requirement.parse('certifi==2015.11.20'))
----------------------------------------
Cleaning up...
I am using Python 2.7. Anybody knows what is the issue?
It seems like all the problem is because of certifi version conflict
so try downloading the source from here
https://pypi.python.org/pypi/certifi
and install from source
Extract it go into the folder and run this command
sudo python setup.py install
and it should work
peace
I met such a situation when I had already used system package manager like aptitude or pacman to install that very package, or dependency package
(they, pip and system package manager, do not know each other, while they install package at the same folder, some site-package thing, so it's easy to get a file already exist like problem)
You need to see which is conflict, open your python console, try to import it, and see where is it with module_name.file, remove it(or the folder) manually (please backup before problem really solved).
Or just use pip and system package manager to verify which has been already installed

How to use esky on windows with python 3.4?

I'm trying to package an auto updating python 3 application using esky, but cannot get it to work on windows.
I'm trying to get the simplest example from the tutorial to work.
https://github.com/cloudmatrix/esky/tree/master/tutorial/stage1
My environment:
Z:\share_space\esky-master\tutorial\stage1>python --version
Python 3.4.3
Z:\share_space\esky-master\tutorial\stage1>pip freeze
...
cx-Freeze==4.3.4
esky==0.9.8
py2exe==0.9.2.2
...
When run using py2exe as the freezer, it fails to find the py2exe module for some reason (though freezing other apps with "python setup.py py2exe" works just fine).
Z:\share_space\esky-master\tutorial\stage1>python setup.py bdist_esky
running bdist_esky
Traceback (most recent call last):
File "setup.py", line 17, in <module>
"freezer_module":"py2exe",
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 973, in run_command
cmd_obj.ensure_finalized()
File "C:\Python34\lib\distutils\cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "C:\Python34\lib\site-packages\esky\bdist_esky\__init__.py", line 291, in
finalize_options
raise RuntimeError(err)
RuntimeError: freezer module not found: 'py2exe'
With cx-Freeze building the package works well but running the executable fails.
Z:\share_space\esky-master\tutorial\stage1>dist\example-app-0.1.win32\example.ex
e
ValueError: bad marshal data (unknown type code)
Fatal Python error: unable to locate initialization module
Current thread 0x00001254 (most recent call first):
In order got get a working windows build you need the following:
The latest esky version from github (not pypi).
To circumvent an esky bug ensure the character case of dependencies listed with pip freeze are correct and reinstall if not.
I can confirm using cx-Freeze works (py2exe not tested yet).
See this github issue as to how the problem was resolved.

Howto install distribute for Python 3

I am trying to install distribute using ActivePython 3.1.2 on Windows.
Running python distribute_setup.py as described on the cheese shop give me:
No setuptools distribution found
running install
Traceback (most recent call last):
File "setup.py", line 177, in
scripts = scripts,
File "C:\Dev\Python_x86\3.1\lib\distutils\core.py", line 149, in setup
dist.run_commands()
File "C:\Dev\Python_x86\3.1\lib\distutils\dist.py", line 919, in run_commands
self.run_command(cmd)
File "C:\Dev\Python_x86\3.1\lib\distutils\dist.py", line 938, in run_command
cmd_obj.run()
File "build\src\setuptools\command\install.py", line 73, in run
self.do_egg_install()
File "build\src\setuptools\command\install.py", line 82, in do_egg_install
easy_install = self.distribution.get_command_class('easy_install')
File "build\src\setuptools\dist.py", line 361, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File "build\src\pkg_resources.py", line 1953, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "build\src\setuptools\command\easy_install.py", line 16, in
from setuptools.sandbox import run_setup
File "build\src\setuptools\sandbox.py", line 164, in
fromlist=['name']).file)
AttributeError: 'module' object has no attribute 'file'
Something went wrong during the installation.
See the error message above.
Is there possibly an unknown dependency that I'm missing?
Downloading the source tarball and executing python setup.py install produces the exact same output.
Edit: Added the full stack trace for running the installer.
So apparently the python.org version of Python3 is different from the ActiveState version of Python3. (You should file a bug to someone (I'm not sure to whom))
The fix I have (I'm not sure of all the repercussions)
Download:
http://pypi.python.org/packages/source/d/distribute/distribute-0.6.12.tar.gz#md5=5a52e961f8d8799d243fe8220f9d760e
and then extracting it and modify:
distribute-0.6.12\setuptools\sandbox.py:165
from:
except ImportError:
to
except (ImportError, AttributeError):
that will silence the error and allow you to run:
python setup.py install
It took me awhile to find a package from http://pypi.python.org/pypi?:action=browse&c=533&show=all that would actually install on either version of Python3. "files" was the first package, and since it installed I am pretty sure that easy_install is working for both copies of Python3.
...hope it works! (That's all I can help you with)
this is a bug with Distribute http://bitbucket.org/tarek/distribute/issue/151 ... it should be fixed by next release (0.6.13). It is only reproducible with PyWin32 installed; and ActivePython comes bundled with PyWin32.

Categories