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

「NameError: name 'packbits' is not defined」で落ちました。 #8

Open
7lucyseven opened this issue Mar 7, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@7lucyseven
Copy link

素晴らしいソフトをありがとうございます。

pytoshopのcodecs.pyでエラーが出ました。
原因は「NameError: name 'packbits' is not defined」とあるように「packbits」がなかったからです。
「codecs.py」でインポートエラーがスルーされていました。
pipでインストールするとエラーは解消されました。
私の環境固有のエラーか共通のエラーか不明ですが、取り急ぎ共有になります。

pip install packbits

実行時の出力全文

(layer) C:\Users\Creator\Desktop\layer\layerdivider>python launch.py share
Running on local URL:  http://127.0.0.1:7860

Could not create share link, please check your internet connection.
C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\sklearn\cluster\_kmeans.py:870: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning
  warnings.warn(
100%|██████████████████████████████████████████████████████████████████████████████████| 10/10 [00:12<00:00,  1.22s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 10/10 [00:12<00:00,  1.21s/it]
100%|████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:10<00:00,  1.21s/it]
100%|████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:05<00:00,  1.24it/s]
100%|████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:02<00:00,  2.52it/s]
100%|████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:02<00:00,  2.44it/s]
100%|████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:02<00:00,  2.44it/s]
Traceback (most recent call last):
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\gradio\routes.py", line 337, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\gradio\blocks.py", line 1015, in process_api
    result = await self.call_function(
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\gradio\blocks.py", line 833, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "C:\Users\Creator\Desktop\layer\layerdivider\launch.py", line 38, in divide_layer
    filename = save_psd(
  File "C:\Users\Creator\Desktop\layer\layerdivider\scripts\utils.py", line 52, in save_psd
    psd.write(fd2)
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\pytoshop\core.py", line 281, in write
    self.layer_and_mask_info.write(fd, self)
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\pytoshop\layers.py", line 1430, in write
    self.layer_info.write(fd, header)
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\pytoshop\layers.py", line 1226, in write
    layer.write_channel_data(fd, header)
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\pytoshop\layers.py", line 1120, in write_channel_data
    lengths.append(data.write(fd, header, shape))
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\pytoshop\layers.py", line 602, in write
    codecs.compress_image(
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\pytoshop\codecs.py", line 488, in compress_image
    return compressors[compression](fd, image, depth, version)
  File "C:\Users\Creator\anaconda3\envs\layer\lib\site-packages\pytoshop\codecs.py", line 331, in compress_rle
    packed = packbits.encode(row)
NameError: name 'packbits' is not defined
@mattyamonaca
Copy link
Owner

共有いただきありがとうございます。
pytoshopのインストールに問題があり、pytoshopをインストールする前に、cythonのインストールをする必要があるようです。
mdboom/pytoshop#9

pytoshopのインストールをサポートする改修を後ほど行います。

@mattyamonaca mattyamonaca added the bug Something isn't working label Mar 20, 2023
@stdarkpha
Copy link

i also get this kind of error even when the packbits is already installed.

PS C:\ai\layerdivider> pip install packbits
Requirement already satisfied: packbits in c:\users\ayaya\appdata\local\programs\python\python310\lib\site-packages (0.6)

PS C:\ai\layerdivider> .\run_gui.ps1
Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch().
C:\ai\layerdivider\venv\lib\site-packages\sklearn\cluster_kmeans.py:870: FutureWarning: The default value of n_init will change from 10 to 'auto' in 1.4. Set the value of n_init explicitly to suppress the warning
warnings.warn(
100%|██████████████████████████████████████████████████████████████████████████████████| 10/10 [00:24<00:00, 2.45s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 10/10 [00:24<00:00, 2.48s/it]
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:20<00:00, 2.51s/it]
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:13<00:00, 1.65s/it]
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:06<00:00, 1.27it/s]
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:06<00:00, 1.23it/s]
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:06<00:00, 1.22it/s]
Traceback (most recent call last):
File "C:\ai\layerdivider\venv\lib\site-packages\gradio\routes.py", line 337, in run_predict
output = await app.get_blocks().process_api(
File "C:\ai\layerdivider\venv\lib\site-packages\gradio\blocks.py", line 1015, in process_api
result = await self.call_function(
File "C:\ai\layerdivider\venv\lib\site-packages\gradio\blocks.py", line 833, in call_function
prediction = await anyio.to_thread.run_sync(
File "C:\ai\layerdivider\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\ai\layerdivider\venv\lib\site-packages\anyio_backends_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "C:\ai\layerdivider\venv\lib\site-packages\anyio_backends_asyncio.py", line 867, in run
result = context.run(func, *args)
File "C:\ai\layerdivider\launch.py", line 38, in divide_layer
filename = save_psd(
File "C:\ai\layerdivider\scripts\utils.py", line 52, in save_psd
psd.write(fd2)
File "C:\ai\layerdivider\venv\lib\site-packages\pytoshop\core.py", line 281, in write
self.layer_and_mask_info.write(fd, self)
File "C:\ai\layerdivider\venv\lib\site-packages\pytoshop\layers.py", line 1430, in write
self.layer_info.write(fd, header)
File "C:\ai\layerdivider\venv\lib\site-packages\pytoshop\layers.py", line 1226, in write
layer.write_channel_data(fd, header)
File "C:\ai\layerdivider\venv\lib\site-packages\pytoshop\layers.py", line 1120, in write_channel_data
lengths.append(data.write(fd, header, shape))
File "C:\ai\layerdivider\venv\lib\site-packages\pytoshop\layers.py", line 602, in write
codecs.compress_image(
File "C:\ai\layerdivider\venv\lib\site-packages\pytoshop\codecs.py", line 488, in compress_image
return compressors[compression](fd, image, depth, version)
File "C:\ai\layerdivider\venv\lib\site-packages\pytoshop\codecs.py", line 331, in compress_rle
packed = packbits.encode(row)
NameError: name 'packbits' is not defined

@BrathonBai
Copy link

I also get this kind of error ,however I get a wheel of pytoshop,after the wheel installed,bug fixed up.
https://download.lfd.uci.edu/pythonlibs/archived/pytoshop-1.2.1-cp310-cp310-win_amd64.whl

@wangwenqiao666
Copy link

wangwenqiao666 commented Apr 17, 2024

git clone https://github.com/mdboom/pytoshop.git
cd pytoshop
python setup.py install build_ext --inplace

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

5 participants