Disclaimer: I am a beginner at using this forum, and relatively new to coding, so if there is anything I have done incorrectly, please let me know.
Hi. I am trying to use pyserial to get values from my arduino's serial monitor, but whenever I use serial.Serial(), I get an error, which says; "cannot find reference 'Serial' in 'imported module serial'". I think the pyserial module is importing fine, its just that I can't actually code with serial.Serial(). I have attached a few images of the simple code and the error. I am using a python IDE called PyCharm, which is version 2021.1.
I have looked at various forums regarding similar problems to mine, but either none had my problem, or I didn't understand how to fix it. Both of these forums discuss an error which says "module has no attribute Serial", but my error is "cannot find reference 'Serial' in 'imported module serial'". Here are links to some forums I've tried to use: https://stackoverflow.com/questions/11403932/python-attributeerror-module-object-has-no-attribute-serial
If you have any ideas what my problem may be, or if you need more information about my situation to help me, please let me know.
Edit: I'm also seeing that there is a different error when I try to use serial.Serial() in the terminal, as opposed to pycharm. In pycharm, I get "Cannot find reference 'Serial' in 'imported module serial'", but in the terminal, I get "module 'serial' has no attribute 'Serial'".
Hi. Thanks for the answer. Unfortunately, I already have pyserial installed, and didn't have serial installed. I am still getting the same error message.
@tim268 the advice from jfjlaros seems the most likely fix, I would try again and check to make sure I had no 'serial' module installed (type help('modules') to view modules in the REPL) before I installed pyserial. The error message suggests that you have a serial module installed but it appears not to be the right module
Hi. I see that I do not have any module named serial when I type help('modules'), both in pycharm and in the terminal. However, there is also no module named pyserial there. But when I write "import serial", it seems to work fine. I don't understand, is import serial for pyserial? Either way, import serial or import pyserial neither work.
I'm also seeing that there is a different error when I try to use serial.Serial() in the terminal, as opposed to pycharm. In pycharm, I get "Cannot find reference 'Serial' in 'imported module serial'", but in the terminal, I get "module 'serial' has no attribute 'Serial'".
@tim268 the objective is to remove any and all serial modules and then install pyserial, when pyserial is installed it will show as 'serial' in the modules list.
In the terminal if you type dir('serial') the list it produces should include 'Serial' , note the upper case 'S' , if Serial is not present the IDE will complain "Cannot find reference 'Serial' in 'imported module serial'
You are right, there is no 'Serial' there. However, I have uninstalled 'serial', and installed 'pyserial'. Why is this still happening? I have attached pictures of the terminal, when I type dir('serial'), when I try to uninstall serial, and when I try to install pyserial.
Typing dir('serial') into terminal (in python 3):
Uninstalling serial and installing pyserial messages:
@tim268 sorry I gave you some wrong info in my last post, I will correct that in a second. Looking at your install/uninstall log try the following in your terminal
Help on package serial:
NAME
serial
DESCRIPTION
# This is a wrapper module for different platform implementations
#
# This file is part of pySerial. https://github.com/pyserial/pyserial
# (C) 2001-2020 Chris Liechti <cliechti@gmx.net>
#
# SPDX-License-Identifier: BSD-3-Clause
Thanks for the advice. I'm now getting 'Serial' showing up and working in python 3 inside the terminal, but I am still getting the Cannot Find Reference error in the pycharme ide. Do you know why this may be?
I'm getting the exact same thing. There was a comment from "sumguy" which seems to have solved the problem in the terminal, but I'm getting the same error in the pycharm IDE. Any ideas what's different when it is there?
Thanks a ton for the link. I just had to uninstall and then install the module, and now I'm not getting any error. Thank you so much for all your help.
Instead of prepending "[solved]" to the subject, you can select the most helpful post as the solution using the "Solution" checkbox. This will lead people with the same question to the correct answer directly.