engineerjoe440 / ElectricPy

Electrical Engineering Formulas in Python
https://electricpy.readthedocs.io/en/latest/
MIT License
86 stars 16 forks source link

Problem installing a package in Visual Studio 2019 #1

Closed DmitryPetrichenko closed 4 years ago

DmitryPetrichenko commented 4 years ago

Hello!

I tried to install a package in Visual Studio 2019. All the necessary and listed packages were installed successfully. The installation of ElectricPy failed (see below).

Thank you.

----- Installing 'electricpy==0.1.4' ----- Collecting electricpy==0.1.4 Using cached electricpy-0.1.4.tar.gz (71 kB) ERROR: Command errored out with exit status 1: command: 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\setup.py'"'"'; file='"'"'C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\pip-egg-info' cwd: C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\ Complete output (7 lines): Traceback (most recent call last): File "", line 1, in File "C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\setup.py", line 11, in file_str = fh.read() File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\encodings\cp1251.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 43488: character maps to

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ----- Failed to install 'electricpy==0.1.4' -----

engineerjoe440 commented 4 years ago

Hi @DmitryPetrichenko !

Thanks for posting the issue! From the traceback, it looks like VS 2019 is having trouble with the egg for some reason... Have you tried installing from source (i.e. clone/download source code and use python setup.py install)?

To confirm, you're using Visual Studio 2019, not Visual Studio Code? Are you using pip or something built into VS? I'm not familiar with Visual Studio integration with Python, unfortunately...

Let me know what you're using, and I'll try to replicate here. Also, if you can, please try installing from source if you haven't already.

DmitryPetrichenko commented 4 years ago

Hello, @engineerjoe440 !

Thank you for the prompt reply! also I thought it might have been a problem with VS2019, so I installed a separate latest version of python 3.8. Then I tried cloning and installing electricpy using the command that you provided. The problem still exists:

d:\SoftProjects\Python\ElectricPy>python setup.py install Traceback (most recent call last): File "setup.py", line 11, in <module> file_str = fh.read() File "C:\Python\Python38-32\lib\encodings\cp1251.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 43817: character maps to <undefined>

I suppose it concerns the encoding and codepage CP1251 (cyrillic) that is used on my computer. Maybe that information would help.

Kind regards!

engineerjoe440 commented 4 years ago

Hi @DmitryPetrichenko! That gives us something!

If you feel comfortable, go ahead and pop the setup.py file open in and editor and change line 10 to specify the encoding as "utf-8".

# Gather Version Information from Python File
with open("electricpy/__init__.py", encoding="utf-8") as fh:
    file_str = fh.read()

Then try running that setup file again. This is a pretty common issue that I overlooked (and didn't see due to my own negligence), and there's some documentation on StackOverflow on it: https://stackoverflow.com/questions/9233027/unicodedecodeerror-charmap-codec-cant-decode-byte-x-in-position-y-character

Let me know if that change works to solves that latest issue you're running into.

Thanks again!

DmitryPetrichenko commented 4 years ago

Hello @engineerjoe440 ,

Thank you! It worked pretty well with direct encoding specification and manual installation into environment.

Kind regards!

engineerjoe440 commented 4 years ago

Glad that worked! Best wishes!