Having Python 3.7.6
and having already installed pyserial
,
pip install pyserial --user
Requirement already satisfied: pyserial in c:\users\myusername\appdata\local\programs\python\python37\lib\site-packages (3.4)
pip install pyserial
Requirement already satisfied: pyserial in c:\users\myusername\appdata\local\programs\python\python37\lib\site-packages (3.4)
I expect that I can import serial
via import serial
which fails.
No module named 'serial'
This is as follows
python3
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 01:54:44) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'serial'
Am I doing any mistake?
PS. The result of import sys; print(sys.path)
is
[
'',
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\\python37.zip',
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\\DLLs',
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\\lib',
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0',
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\\lib\\site-packages'
]
PS. The result of where pip
is
C:\Users\myusername\AppData\Local\Programs\Python\Python37\Scripts\pip.exe
C:\Users\myusername\AppData\Local\Microsoft\WindowsApps\pip.exe
Firstly, You've installed python from Windows Store. Then You decided to install python using official installer. As a result You've got 2 pythons installed:
C:\Users\%username%\AppData\Local\Microsoft\WindowsApps\python.exe
;C:\Users\%username%\AppData\Local\Programs\Python\Python37\python.exe
.Each installer add path to python into PATH and here is the problem.
When you have two executables with same name (python.exe, pip.exe, etc.) in different directories which added to PATH You let OS choose which to launch. In Your case OS launches python.exe from ..WindowsApps\
directory and pip.exe from ..Python37\Scripts\
.
How to fix that:
Press ā Win+R and type sysdm.cpl
:
Switch to tab "Advanced" and press button "Environment variables":
In opened window you'll see 2 tables representing environment variables for current user (table on the top) and for whole system (table on the bottom).
You need to select valiable "Path" on each of these tables and press "Edit" under the table: