Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"tgcf-web" command gives this error on Mac #594

Open
manjulsigdel opened this issue Apr 22, 2024 · 7 comments
Open

"tgcf-web" command gives this error on Mac #594

manjulsigdel opened this issue Apr 22, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@manjulsigdel
Copy link

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/python@3.12/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/python@3.12/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/python@3.12/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/python@3.12/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/python@3.12/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 manjulsigdel added the bug Something isn't working label Apr 22, 2024
@a-dev1
Copy link

a-dev1 commented May 13, 2024

I am also facing the same issue on Mac.

@a-dev1
Copy link

a-dev1 commented May 15, 2024

@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.

@dymbox
Copy link

dymbox commented May 23, 2024

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

@shaotingchang
Copy link

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

@EverLife0-0
Copy link

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

@nmaiti
Copy link
Contributor

nmaiti commented Aug 12, 2024

please use docker based deployments, for compatibility issues

@irmmr
Copy link

irmmr commented Nov 26, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants