click command line within conda environment- mac m1 chip

Viewed 111

I am currently working with tensorflow on a new mac with M1 chip.

As you might know, getting tensorflow to work on the M1 chip is a bit messy but I managed to do it following this tutorial: https://github.com/mrdbourke/m1-machine-learning-test

Now, I have an environment named tensorflow-test with python 3.8 and tensorflow correctly installed (I can import it without errors).

Within this environment, I want to build some command lines using click package. I used to have everything integrated beautifully until, for some weird reason, I messed up with the environment and now I can't figure out what is going on.

A simple code to reproduce what I have is the following. Within the tensorflow-test conda environment I have a file with click code hello.py:

import click
import tensorflow


@click.command()
@click.option('--count', default=1, help='Number of greetings.')
@click.option('--name', prompt='Your name',
              help='The person to greet.')
def cli(count, name):
    """Simple program that greets NAME for a total of COUNT times."""
    for x in range(count):
        click.echo("Hello {name}!")


if __name__ == '__main__':
    cli()

and another with the set up, setup.py :

from setuptools import setup

setup(
    name="hello",
    version='0.1',
    py_modules=['hello'],
    author='xxx',
    install_requires=[
        'Click',
        'pandas',
        'tensorflow',
    ],
    entry_points='''
        [console_scripts]
         hello=hello:cli
    ''',
   
)

When I run it using python hello.py everything seems to be working fine. However, when I try to integrate this to be run directly as a command line, I do

pip install --editable .

and the following error appears:

Requirement already satisfied: Click in ./env/lib/python3.8/site-packages (from hello==0.1) (8.0.4)
Requirement already satisfied: pandas in ./env/lib/python3.8/site-packages (from hello==0.1) (1.4.2)
ERROR: Could not find a version that satisfies the requirement tensorflow (from hello) (from versions: none)
ERROR: No matching distribution found for tensorflow

I checked and there is a folder named tensorflow in ./env/lib/python3.8/site-packages.

What is going on? Why can't I use hello directly as a command when everything seems to be working fine otherwise?

1 Answers

It seems that I got it to work now but it is till unclear to me what is the exact reason.

I managed to retrieve the old environment file and I realised that within $HOME/tensorflow-test/env/lib/python3.8/site-packages some files related to tensorboard were missing.

My hunch is that these are the ones beeing installed under the tensorflow dependencies in the link above conda install -c apple tensorflow-deps

The weird thing is that when running this command it produces an error so the only way to make it work is to copy paste them from my previous environment...

I will update if I manage to figure out more things.

EDIT: I am now experiencing issues with installation of new packages.

For instance, when using pip install pyautogui everything is satisfied but when trying to import it within the environment this appears:

Traceback (most recent call last):
  File "/Users/luisignaciomenendezgarcia/tensorflow-test/env/lib/python3.8/site-packages/pyautogui/_pyautogui_osx.py", line 5, in <module>
    import Quartz
  File "/Users/luisignaciomenendezgarcia/tensorflow-test/env/lib/python3.8/site-packages/Quartz/__init__.py", line 110, in <module>
    _load()
  File "/Users/luisignaciomenendezgarcia/tensorflow-test/env/lib/python3.8/site-packages/Quartz/__init__.py", line 28, in _load
    from Quartz import CoreGraphics as m
  File "/Users/luisignaciomenendezgarcia/tensorflow-test/env/lib/python3.8/site-packages/Quartz/CoreGraphics/__init__.py", line 13, in <module>
    from Quartz.CoreGraphics._inlines import _inline_list_
ImportError: dlopen(/Users/luisignaciomenendezgarcia/tensorflow-test/env/lib/python3.8/site-packages/Quartz/CoreGraphics/_inlines.abi3.so, 0x0002): tried: '/Users/luisignaciomenendezgarcia/tensorflow-test/env/lib/python3.8/site-packages/Quartz/CoreGraphics/_inlines.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_inlines.abi3.so' (no such file), '/usr/lib/_inlines.abi3.so' (no such file)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/luisignaciomenendezgarcia/tensorflow-test/env/lib/python3.8/site-packages/pyautogui/__init__.py", line 166, in <module>
    from . import _pyautogui_osx as platformModule
  File "/Users/luisignaciomenendezgarcia/tensorflow-test/env/lib/python3.8/site-packages/pyautogui/_pyautogui_osx.py", line 7, in <module>
    assert False, "You must first install pyobjc-core and pyobjc: https://pyautogui.readthedocs.io/en/latest/install.html"
AssertionError: You must first install pyobjc-core and pyobjc: https://pyautogui.readthedocs.io/en/latest/install.html

Exactly the same occurs with the module keyboard.

There is no problem if I mode out of the environment though.

Related