Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnicodeDecodeError: 'charmap' codec| Error during installation of pip python-stdnum==1.8

I am fairly new to programming, so please bear with me.

While I was installing some required packages for a module that I'm using, I wasn't able to install python-stdnum==1.8.

I got the following error message:

File "C:\Users\59996\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 967: character maps to <undefined>
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Is there anything I can do to still be able to install the package?

Any help would be greatly appreciated. Thanks in advance!

like image 687
Nomad_King Avatar asked Jan 21 '21 02:01

Nomad_King


2 Answers

If it's for the Odoo 14 install on Windows, the issue is in the "requirements.txt"

Change "python-stdnum==1.8" to "python-stdnum==1.8.1" (even if the answer of Federico Baù is working by the way)

then another issue will appear so change "psutil==5.6.6" to "psutil==5.6.7" still in the "requirements.txt"

source: https://github.com/odoo/odoo/issues/62919

Best regards

like image 60
Adri Avatar answered Oct 01 '22 00:10

Adri


I ran to the same problem while installing Odoo Dependencies in Windows, but after some tacke I found a solution.

It's a old bug with stdnum 1.8 --> stdnum 1.8 installation fails on windows.

  • setup.py: Open README with utf-8 encoding.

Solution

  1. Go to arthurdejong.org/python-stdnum/ and find python-stdnum-1.8.tar.gz

  2. Download the Zip in a folder, rename it from python-stdnum-1.8.tar.gz to python-stdnum-1.8.tar_.gz (Just to avoid name collision).

  3. Then create the following Python Script (in the same directory):


import tarfile

def open_tarfile_function(tarfile_file_name):
    open_tarfile=tarfile.open("python-stdnum-1.8.tar_.gz")
    open_tarfile.extractall(path='stdnum')
    open_tarfile.close()

open_tarfile_function('data.tgz')

  1. It will create a folder named stdnum, open it and then open setup.py, go to line 37 and modify from this:

with open(os.path.join(base_dir, 'README'), 'r') as fp:
    long_description = fp.read()

To this:

with open(os.path.join(base_dir, 'README'), 'rb') as fp:
    long_description = fp.read().decode('utf-8')

Save it.

  1. Now in the same Directory run this code:

import tarfile
import os.path

def make_tarfile(output_filename, source_dir):
    with tarfile.open(output_filename, "w:gz") as tar:
        tar.add(source_dir, arcname=os.path.sep)

output_filename = "python-stdnum-1.8.tar.gz"
source_dir = "stdnum\python-stdnum-1.8"

make_tarfile(output_filename, source_dir)

  1. This will create file python-stdnum-1.8.tar.gz copy the Absolute Path

  2. Go to your Python Environment and run:


pip install D:\Odoo\Odoo_instance_one\python-stdnum-1.8.tar.gz

Obviously replace the Absolute Path with your absolute path.

like image 27
Federico Baù Avatar answered Sep 30 '22 23:09

Federico Baù