tgcf icon indicating copy to clipboard operation
tgcf copied to clipboard

"tgcf-web" command gives this error on Mac

Open manjulsigdel opened this issue 1 year ago • 8 comments

Traceback (most recent call last): File "/Users/manjulsigdel/Projects/my-tgcf/.venv/bin/tgcf-web", line 8, in sys.exit(main()) ^^^^^^ File "/Users/manjulsigdel/Projects/my-tgcf/.venv/lib/python3.12/site-packages/tgcf/web_ui/run.py", line 8, in main package_dir = resources.path(package=wu, resource="").enter() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/resources/_legacy.py", line 25, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/resources/_legacy.py", line 120, in path return _common.as_file(_common.files(package) / normalize_path(resource)) ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/resources/abc.py", line 133, in truediv return self.joinpath(child) ^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/resources/readers.py", line 92, in joinpath return super().joinpath(*descendants) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/resources/abc.py", line 117, in joinpath target = next(names) ^^^^^^^^^^^ StopIteration

How to reproduce Just installed following Readme

python version 3.12.3 pip version 24.0 Macbook Air M1 Chip

manjulsigdel avatar Apr 22 '24 01:04 manjulsigdel

I am also facing the same issue on Mac.

a-dev1 avatar May 13 '24 10:05 a-dev1

@aahnik @nmaiti @MobCode100 @FloPinguin @Matt3oV , I guess most of the mac users are facing the same issue, please look into the matter as soon as possible.

a-dev1 avatar May 15 '24 13:05 a-dev1

Same here, python3.12, neither downloaded .pkg, nor brew installed works

dymbox avatar May 23 '24 08:05 dymbox

In the same boat over here. Any help would be greatly appreciated!

shaotingchang avatar May 23 '24 13:05 shaotingchang

same here: mac m1, windows 10. both have python 3.12

EverLife0-0 avatar Aug 11 '24 23:08 EverLife0-0

please use docker based deployments, for compatibility issues

nmaiti avatar Aug 12 '24 08:08 nmaiti

I'm not a python programmer!

These changes are temporary, and the explanations below are generated by ChatGPT to save time. Here's a step-by-step explanation:

1. Install vim and streamlit:

First, I installed vim, a text editor for editing Python files, and then installed the specific version of streamlit that I needed:

apt install vim
pip3 install streamlit==1.32

2. Get the location of the tgcf package:

To find out where the tgcf package is installed in the Python environment, I ran the following command:

pip3 show tgcf

This command provides detailed information about the tgcf package, including its installation path. Here's an example of the output you might see:

Name: tgcf
...
Location: /home/.venv/lib/python3.12/site-packages

The Location line shows the directory where tgcf is installed. You'll need this path to navigate to the web_ui directory in the next steps.

3. Navigate to the tgcf package directory:

After finding the tgcf package location, I navigated to the tgcf directory inside the virtual environment:

cd /home/.venv/lib/python3.12/site-packages/tgcf
cd web_ui

4. Edit run.py:

I opened the run.py file inside the web_ui folder using vim to make the necessary changes:

vim run.py

4. Import tgcf:

Inside the run.py file, I added the following import at the top of the script to make the tgcf package accessible:

import tgcf as tg

5. Fix the resources.path line:

In the original code, there was an issue with accessing the package directory using resources.path. I changed this line:

package_dir = resources.path(package=tg, resource="").__enter__()

to a safer version that works by using a str() conversion. This is because resources.path returns a context manager, which needs to be handled properly. The updated line looks like this:

package_dir = str(package_dir) + "/web_ui"

This modification correctly defines the path to the web_ui directory within the tgcf package, which ensures everything works as expected.

irmmr avatar Nov 26 '24 15:11 irmmr

Another workaround is to run tgcf-web under Python 3.11, e.g. uvx --from tgcf --python 3.11 tgcf-web

Chaoses-Ib avatar Mar 30 '25 19:03 Chaoses-Ib