Skocz do zawartości
Opublikowano

Doberek,

Mam problem z pobraniem python3 na FreeBSD 12x ( czy na innych też jest ten problem? Nie wiem bo używam 12x )

Po zainstalowaniu cały czas jest to samo:

Spoiler


  File "skrypt.py", line 3, in <module>
    import chardet
ModuleNotFoundError: No module named 'chardet'
 

pkg install -f python39 py39-pip

Spoiler

root@mt2:~ # pkg install -f python39 py39-pip
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
Fetching packagesite.txz: 100%    6 MiB   6.7MB/s    00:01
Processing entries:   0%
Newer FreeBSD version for package zstd:
To ignore this error set IGNORE_OSVERSION=yes
- package: 1204000
- running kernel: 1201000
Ignore the mismatch and continue? [Y/n]: y
Processing entries: 100%
FreeBSD repository update completed. 32912 packages processed.
All repositories are up to date.
New version of pkg detected; it needs to be installed first.
The following 1 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
        pkg: 1.13.2 -> 1.19.2

Number of packages to be upgraded: 1

The process will require 3 MiB more space.
7 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching pkg-1.19.2.pkg: 100%    7 MiB   7.4MB/s    00:01
Checking integrity... done (0 conflicting)
[1/1] Upgrading pkg from 1.13.2 to 1.19.2...
[1/1] Extracting pkg-1.19.2: 100%
pkg: Failed to execute lua script: [string "-- args: etc/pkg.conf.sample..."]:12                                                  : attempt to call a nil value (field 'stat')
pkg: lua script failed
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 6 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        libffi321: 3.2.1_3
        mpdecimal: 2.5.1
        py39-pip: 23.1.2
        py39-setuptools: 63.1.0_1
        python39: 3.9.18

Installed packages to be UPGRADED:
        libffi: 3.2.1_3 -> 3.4.4

Number of packages to be installed: 5
Number of packages to be upgraded: 1

The process will require 145 MiB more space.
21 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/6] Fetching mpdecimal-2.5.1.pkg: 100%  329 KiB 337.2kB/s    00:01
[2/6] Fetching libffi-3.4.4.pkg: 100%   39 KiB  40.2kB/s    00:01
[3/6] Fetching libffi321-3.2.1_3.pkg: 100%   13 KiB  13.6kB/s    00:01
[4/6] Fetching python39-3.9.18.pkg: 100%   17 MiB   6.1MB/s    00:03
[5/6] Fetching py39-pip-23.1.2.pkg: 100%    3 MiB   2.7MB/s    00:01
[6/6] Fetching py39-setuptools-63.1.0_1.pkg: 100%    1 MiB   1.1MB/s    00:01                                                     
Checking integrity... done (0 conflicting)
[1/6] Installing mpdecimal-2.5.1...
[1/6] Extracting mpdecimal-2.5.1: 100%
[2/6] Upgrading libffi from 3.2.1_3 to 3.4.4...
[2/6] Extracting libffi-3.4.4: 100%
[3/6] Installing python39-3.9.18...
[3/6] Extracting python39-3.9.18: 100%
[4/6] Installing py39-setuptools-63.1.0_1...
[4/6] Extracting py39-setuptools-63.1.0_1: 100%
[5/6] Installing libffi321-3.2.1_3...
[5/6] Extracting libffi321-3.2.1_3: 100%
[6/6] Installing py39-pip-23.1.2...
[6/6] Extracting py39-pip-23.1.2: 100%
=====
Message from python39-3.9.18:

--
Note that some standard Python modules are provided as separate ports
as they require additional dependencies. They are available as:

py39-gdbm       databases/py-gdbm@py39
py39-sqlite3    databases/py-sqlite3@py39
py39-tkinter    x11-toolkits/py-tkinter@py39
=====
Message from libffi321-3.2.1_3:

--
===>   NOTICE:

The libffi321 port currently does not have a maintainer. As a result, it is
more likely to have unresolved issues, not be up-to-date, or even be removed in
the future. To volunteer to maintain this port, please create an issue at:

https://bugs.freebsd.org/bugzilla

More information about port maintainership is available at:

https://docs.freebsd.org/en/articles/contributing/#ports-contributing
=====
Message from py39-pip-23.1.2:

--
pip MUST ONLY be used:

 * With the --user flag, OR
 * To install or manage Python packages in virtual environments

Failure to follow this warning can and will result in an inconsistent
system-wide Python environment (LOCALBASE/lib/pythonX.Y/site-packages) and
cause errors.

Avoid using pip as root unless you know what you're doing.
 

 

pip install chardet

Spoiler

root@mt2:~ # pip install chardet
Collecting chardet
  Downloading chardet-5.2.0-py3-none-any.whl (199 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.4/199.4 kB 3.0 MB/s eta 0:00:00
Installing collected packages: chardet
Successfully installed chardet-5.2.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

 

Rozwiązane przez Sevence

Przejdź do rozwiązania

Featured Replies

Opublikowano
  • Rozwiązanie

Logi mówię że poprawnie zainstalowałeś niezbędne moduły. 

W jaki sposób uruchamiasz skrypt? Możliwe, że uruchamiasz ten skrypt z niepoprawną wersją Pythona. 

 

Spróbuj w ten sposób:

python3.9 nazwaskryptu.py

 

Opublikowano
  • Autor
11 minut temu, Sevence napisał(a):

Logi mówię że poprawnie zainstalowałeś niezbędne moduły. 

W jaki sposób uruchamiasz skrypt? Możliwe, że uruchamiasz ten skrypt z niepoprawną wersją Pythona. 

 

Spróbuj w ten sposób:

python3.9 nazwaskryptu.py

 

dokładnie to..

wpisywałem poprostu python tak jak autor tego kodu XD

++ Dziękuje ❤️

Spoiler

# Script by: Grzyb.ovh
# The script automatically translates the drop from mob_drop_item.txt and special_item_group.txt files, utilizing the information in the locale_name.txt file
import chardet
import codecs

def detect_encoding(filename):
    with open(filename, 'rb') as f:
        result = chardet.detect(f.read())
    return result['encoding']

with codecs.open('item_names.txt', 'r', encoding='cp1250') as source_file:
    contents = source_file.read()

with codecs.open('item_names_utf8.txt', 'w', encoding='utf-8') as target_file:
    target_file.write(contents)

with open('item_names_utf8.txt', 'r', encoding='utf-8') as f:
    item_names = {}
    for line in f:
        if 'VNUM' in line or 'LOCALE_NAME' in line:
            continue
        vnum, name = line.strip().split('\t')
        item_names[vnum] = name

drop_cpp_encoding = detect_encoding('drop.txt')
with open('drop.txt', 'r', encoding=drop_cpp_encoding) as f:
    lines = f.readlines()

new_lines = []
for line in lines:
    if line.startswith('Group') or 'exp' in line:
        new_lines.append(line)
    else:
        parts = line.split('\t')
        if len(parts) > 2 and parts[2] in item_names:
            line = line.rstrip() + ' // ' + item_names[parts[2]] + '\n'
        new_lines.append(line)

with open('drop2.txt', 'w', encoding='utf-8') as f:
    f.writelines(new_lines)

próbuje teraz ogarnąć jak zrobić automatyczne tłumaczenie tego w pliku z dropem bo domyślnie, tworzy mi plik drop.txt i drop2.txt zamiast dodać nazwy itemów z bazy zaraz po dropie

1    14163    1    2 // Kryształowa Bransoleta+3

Opublikowano

Patrząc na ten kod to ten skrypt powinien dokładnie to robić. Musisz mieć w katalogu z tym skryptem plik 'item_names.txt'. W utworzonym pliku 'drop2.txt powinieneś mieć właśnie taką wersję z komentarzami nazw przedmiotów. 

  • Sevence zablokował(a) ten temat
Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.