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.Dismiss alert
Issue:
I encountered a UnicodeEncodeError when running a python script that calls the function "initialize_VPN(area_input=['complete rotation'])" through a .bat file. note issue only exists when executing via .bat file and won't appear when running via an IDE like pyCharm or directly via terminal.
Error:
Traceback (most recent call last):
File "...\main.py", line 3, in
instructions = initialize_VPN(area_input=['complete rotation'])
File "...\ProjectFolder\venv\lib\site-packages\nordvpn_switcher\nordvpn_switch.py", line 142, in initialize_VPN
print("NordVPN installation check: \33[92m\N{check mark}\33[0m")
File "C:\Python310\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' in position 33: character maps to
Environment:
Python version: [3.10]
Operating System: [Windows 10]
Terminal used: [Windows Terminal]
Steps to Reproduce:
create python script main.py:
Content of py file:
from nordvpn_switcher import initialize_VPN, rotate_VPN
instructions = initialize_VPN(area_input=['complete rotation'])
rotate_VPN(instructions)
create bat file named "test.bat" inside the folder of a project created with pyCharm that has module nordvpn-switcher installed.
Content of bat file:
@echo off
REM Replace "venv\Scripts\activate" with the actual path to your virtual environment
call venv\Scripts\activate
REM Run your Python script
python main.py
REM Deactivate the virtual environment
deactivate
pause
Run "test.bat" via terminal .\vpn_switch.bat
Expected Behavior:
The script should run without any UnicodeEncodeError and complete the rotation as intended.
Actual Behavior:
The script raises a UnicodeEncodeError at the following line in nordvpn_switch.py:
python
print("NordVPN installation check: \33[92m\N{check mark}\33[0m")
Possible Fix: (fix only works for versions python 3.7 and above)
add following code to top of file nordvpn_switch.py
import sys
# Check if the platform is Windows
if sys.platform == 'win32':
# Change the encoding to 'utf-8' for Windows terminal
if sys.version_info >= (3, 7):
try:
sys.stdout.reconfigure(encoding='utf-8') # minimum python version of 3.7 is required
except Exception as e:
print(f"An error occurred while reconfiguring stdout: {e}")
The text was updated successfully, but these errors were encountered:
Issue:
I encountered a UnicodeEncodeError when running a python script that calls the function "initialize_VPN(area_input=['complete rotation'])" through a .bat file. note issue only exists when executing via .bat file and won't appear when running via an IDE like pyCharm or directly via terminal.
Error:
Traceback (most recent call last):
File "...\main.py", line 3, in
instructions = initialize_VPN(area_input=['complete rotation'])
File "...\ProjectFolder\venv\lib\site-packages\nordvpn_switcher\nordvpn_switch.py", line 142, in initialize_VPN
print("NordVPN installation check: \33[92m\N{check mark}\33[0m")
File "C:\Python310\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' in position 33: character maps to
Environment:
Steps to Reproduce:
Content of py file:
Content of bat file:
.\vpn_switch.bat
Expected Behavior:
The script should run without any UnicodeEncodeError and complete the rotation as intended.
Actual Behavior:
The script raises a UnicodeEncodeError at the following line in
nordvpn_switch.py
:python
print("NordVPN installation check: \33[92m\N{check mark}\33[0m")
Possible Fix: (fix only works for versions python 3.7 and above)
add following code to top of file nordvpn_switch.py
The text was updated successfully, but these errors were encountered: