embodied icon indicating copy to clipboard operation
embodied copied to clipboard

Windows compatibility

Open platinaCoder opened this issue 1 year ago • 0 comments

I got the following error when installing through pip on windows 11:

Collecting embodied
  Using cached embodied-1.0.2.tar.gz (45 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\nickdv\AppData\Local\Temp\pip-install-dvx6q8ps\embodied_295f71e2acbf47f6885e32bcd7fa7bd6\setup.py", line 32, in <module>
          'dreamerv3': parse_reqs('embodied/agents/dreamerv3/requirements.txt'),
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\nickdv\AppData\Local\Temp\pip-install-dvx6q8ps\embodied_295f71e2acbf47f6885e32bcd7fa7bd6\setup.py", line 8, in parse_reqs
          requirements = requirements.read_text().split('\n')
                         ^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\nickdv\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 1058, in read_text
          with self.open(mode='r', encoding=encoding, errors=errors) as f:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\nickdv\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 1044, in open
          return io.open(self, mode, buffering, encoding, errors, newline)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      FileNotFoundError: [Errno 2] No such file or directory: 'embodied\\agents\\dreamerv3\\requirements.txt'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I had to change the setup.py to make it compatible with windows. I had to get rid of the pathlib dependency and change it to os. I did the following:

Clone the repository and change the setup.py to

 import os
import re
import setuptools

def parse_reqs(filename):
    with open(filename, 'r', encoding='utf-8') as file:
        requirements = file.read().split('\n')
    requirements = [x for x in requirements if x.strip()]
    return requirements

def parse_version(filename):
    base_path = os.path.dirname(__file__)
    full_path = os.path.join(base_path, filename)
    with open(full_path, 'r', encoding='utf-8') as file:
        text = file.read()
    version = re.search(r"__version__ = '(.*)'", text).group(1)
    return version

with open('README.md', 'r', encoding='utf-8') as file:
    long_description = file.read()

setuptools.setup(
    name='embodied',
    version=parse_version('embodied/__init__.py'),
    author='Danijar Hafner',
    author_email='[email protected]',
    description='Fast reinforcement learning research',
    url='http://github.com/danijar/embodied',
    long_description=long_description,
    long_description_content_type='text/markdown',
    packages=setuptools.find_packages(),
    include_package_data=True,
    install_requires=parse_reqs('embodied/requirements.txt'),
    extras_require={
        'dreamerv3': parse_reqs('embodied/agents/dreamerv3/requirements.txt'),
    },
    classifiers=[
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 3',
        'Topic :: Scientific/Engineering :: Artificial Intelligence',
    ],
)

Then in the directory of the cloned repository, open a terminal and run python setup.py install to install the dependency.

platinaCoder avatar Jan 23 '24 14:01 platinaCoder