Python no item named

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

Poetry 1.4.0: There is no item named /WHEEL in the archive #7572

Poetry 1.4.0: There is no item named /WHEEL in the archive #7572

kind/bug Something isn’t working as expected status/external-issue Issue is caused by external project (platform, dep, etc)

Comments

  • Poetry version: 1.4.0
  • Python version: 3.11
  • OS version and name: macOS 13.2.1/MacPorts
  • pyproject.toml: https://gist.github.com/elventear/2410f2f8a05926df27488767cfcab780
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode ( -vvv option) and have included the output below.

Issue

Hypercorn can’t be installed with poetry 1.4.0, it used to be possible to install it:

poetry install Creating virtualenv test in /path/to/.venv Updating dependencies Resolving dependencies. (0.4s) Writing lock file Package operations: 8 installs, 0 updates, 0 removals • Installing h11 (0.14.0) • Installing hpack (4.0.0) • Installing hyperframe (6.0.1) • Installing h2 (4.1.0) • Installing priority (2.0.0) • Installing toml (0.10.2) • Installing wsproto (1.2.0) • Installing hypercorn (0.14.3): Failed Stack trace: 10 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:271 in _execute_operation 269│ 270│ try: → 271│ result = self._do_execute_operation(operation) 272│ except EnvCommandError as e: 273│ if e.e.returncode == -2: 9 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:357 in _do_execute_operation 355│ return 0 356│ → 357│ result: int = getattr(self, f"_execute_")(operation) 358│ 359│ if result != 0: 8 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:477 in _execute_install 475│ 476│ def _execute_install(self, operation: Install | Update) -> int: → 477│ status_code = self._install(operation) 478│ 479│ self._save_url_reference(operation) 7 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:535 in _install 533│ self._remove(operation.initial_package) 534│ → 535│ self._wheel_installer.install(archive) 536│ finally: 537│ if cleanup_archive: 6 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/wheel_installer.py:101 in install 99│ def install(self, wheel: Path) -> None: 100│ with WheelFile.open(Path(wheel.as_posix())) as source: → 101│ install( 102│ source=source, 103│ destination=self._destination.for_source(source), 5 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/_core.py:77 in install 75│ 76│ """ → 77│ root_scheme = _process_WHEEL_file(source) 78│ 79│ # RECORD handling 4 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/_core.py:21 in _process_WHEEL_file 19│ Returns the scheme that the archive root should go in. 20│ """ → 21│ stream = source.read_dist_info("WHEEL") 22│ metadata = parse_metadata_file(stream) 23│ 3 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/sources.py:139 in read_dist_info 137│ """Get contents, from ``filename`` in the dist-info directory.""" 138│ path = posixpath.join(self.dist_info_dir, filename) → 139│ return self._zipfile.read(path).decode("utf-8") 140│ 141│ def get_contents(self) -> Iterator[WheelContentElement]: 2 /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1507 in read 1505│ def read(self, name, pwd=None): 1506│ """Return file bytes for name.""" → 1507│ with self.open(name, "r", pwd) as fp: 1508│ return fp.read() 1509│ 1 /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1544 in open 1542│ else: 1543│ # Get info object for name → 1544│ zinfo = self.getinfo(name) 1545│ 1546│ if mode == 'w': KeyError "There is no item named 'Hypercorn-0.14.3.dist-info/WHEEL' in the archive" at /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1473 in getinfo 1469│ def getinfo(self, name): 1470│ """Return the instance of ZipInfo given 'name'.""" 1471│ info = self.NameToInfo.get(name) 1472│ if info is None: → 1473│ raise KeyError( 1474│ 'There is no item named %r in the archive' % name) 1475│ 1476│ return info 

Wondering if there is a case sensitivity issue. Looking at the wheel, I do see there is a file in hypercorn-0.14.3.dist-info/WHEEL .

Читайте также:  Java может ли конструктор возвращать значение

The text was updated successfully, but these errors were encountered:

Источник

Python no item named

When you try to open the XLSX file, such an error appears

TracEBack: File «C: /Ussers/4R4R5/PycharmProjects/untitled2/main.py», Line 10, In Matcher.Rename_DRUGS () File «C: \ Users \ 4R4R5 \ PycharmProjects \ Untitled2 \ Matcher.py», Line 196, In Rename_Drugs. Self .__ Directory + File) # for files from Directory Creates CSV Copy File «C: \ Users \ 4R4R5 \ PycharmProjects \ Untitled2 \ Matcher.py» Line 94, In __csv_from_excel WB= OpenPyXL.load_Workbook (DataPath) File «C: \ Users \ 4R4R5 \ PycharmProjects \ Untitled2 \ Venv \ Lib \ Site-Packages \ OpenPyXL \ Reader \ Excel.py» Line 314, in Load_Workbook Reader.Read () File «C: \ Users \ 4R4R5 \ PycharmProjects \ Untitled2 \ Venv \ Lib \ Site-Packages \ OpenPyXL \ Reader \ Excel.py» Line 274, In Read self.read_strings () file «C: \ Users \ 4R4R5 \ PycharmProjects \ Untitled2 \ Venv \ Lib \ Site-Packages \ OpenPyXL \ Reader \ Excel.py» Line 143, In Read_Strings With self.archive.open (strings_path,) AS SRC: File «C: \ Users \ 4R4R5 \ APPDATA \ LOCAL \ PROGRAMS \ Python \ Python37 \ lib \ zipfile.py» Line 1470, In Open zinfo= self.getinfo (name) file «C: \ users \ 4R4R5 \ APPDATA \ LOCAL \ PROGRAMS \ Python \ Python37 \ lib \ zipfile.py» Line 1398, in GetInfo ‘There IS No Item Named% R in the Archive’% Name) KEYERROR: «THERE IS NO ITEM NAMED ‘XL /SHAREDSTRINGS.XML’ IN THE ARCHIVE»

def __csv_from_excel (FileName, Datapath): # read from datapath; Write to Filename. Try: If (datapath [-4:])== "XLSX": WB= OpenPyxl.Load_Workbook (DataPath) FileNames= [] Sheets= WB.Sheetnames. For Sheet In Sheets: SH= WB [STR (Sheet)] With Open (FileName [: -4] + Sheet + ".csv", 'Tw', newLine= '') AS F: FileNames.APPEND (FileName [: -4] + Sheet + ".csv") wr= csv.writer (F, quoting= csv.quote_all, delimiter= ";") For row in sh .rows: TEMP= [] For Cell In Row: Temp.APPEND (Cell.Value) WR.WRITEROW (TEMP) F.Close () Return Filenames. ELIF (Datapath [-4:])== ".xls": WB= xlrd.open_Workbook (Datapath, Encoding_override= "CP1251") Sheetlist= WB.Sheet_Names () FileNames= [] For Sheet In Sheetlist: SH= WB.Sheet_BY_NAME (Sheet) With Open (FileName [: -4] + Sheet + ".csv", 'Tw', newLine= '') AS F: FileNames.APPEND (FileName [: -4] + Sheet + ".csv") wr= csv.writer (F, quoting= csv.quote_all, delimiter= ";") For RowNum in Range (Sh.Nrows): WR.WRITEROW (SH.ROW_VALUES (ROWNUM)) F.Close () Return Filenames. Except UnicodeDeDeError: Print (Datapath) 

Tell me please what could be the reason

Читайте также:  Php прекратить выполнение функции

Probably these files are formed in 1C?

Sergey Gornostaev 2021-09-18 15:46:24

@SergeyGornostaev I will definitely not say, since I do not form them yourself, but most likely it is

dimonamana 2021-09-18 15:46:24

I had the same problem with Excel files that were generated in 1C. That your code accepted the file, you need to change something in it (the width of the cells, the color of the cells, something and change). Then pays.

Import Shutil From Zipfile Import Zipfile # Create a temporary folder TMP_Folder= '/TMP /convert_wrong_excel /' OS.Makedirs (TMP_Folder, EXIST_OK= TRUE) # Unpack Excel as zip in our temporary folder With zipfile ('yourfile.xlsx') AS Excel_Container: Excel_Container.ExtractAll (TMP_Folder) # Rename file with the wrong name wrong_file_path= os.path.join (TMP_FOLDER, 'XL', 'SharedStrings.xml') correct_file_path= os.path.join (TMP_Folder, 'XL', 'SharedStrings.xml') os.Rename (Wrong_file_Path, Correct_File_path) # Select Excel back to zip and rename to the source file shutil.make_archive ('Yourfile', 'Zip', TMP_Folder) os.Rename ('Yourfile.zip', 'YourFile.xlsx') 
  • Use the xlrd v 1.2 library -it was a code that took into account such errors in the archive. In the current version -2.x support XLSX from this library thrown out.
  • fix the archive using libreoffice -it can correctly open such files.
  • fix the archive yourself -repaid with the corrected name.
  • # return dictionary of dataset with keys as the names of the EXCEL files file dict_of_dfs= pd.read_excel ('< Path to Excel File > ', Sheet_name= none) # Sheet_name= none returns all sheets 
    df_sheet1= dict_of_dfs ['Sheet 1'] 

    Also if you are going to use libraries to work with Excel files, Pandas can serve as a converter and the data received can be saved as an Excel file:

    df_sheet1.to_excel (excel_writer= '< Path to Save Excel File > ', Sheet_name=' Sheet 1 ') Excel_File= OpenPyxl.load_Workbook (FileName= '< Path to Save Excel File > ') 

    Источник

    Оцените статью