python-can icon indicating copy to clipboard operation
python-can copied to clipboard

Problem using "import can" in PyCharm

Open Darkrem1 opened this issue 2 years ago • 2 comments

Hi guys,

I'm a PLC programmer with just basic knowledge in Python so it is probably just something basic missing.

I've installed python-can in PyCharm. Usng the example "send_one", it acts like it is not installed. I've worked with classes and module but when I type "can. ..." nothing shows for auto-complete like it is not imported correctly

Gettings errors like:

Cannot find reference 'CanError' in 'imported module can'

File "C:\Users\rbeland\PycharmProjects\pythonProject\main.py", line 12, in send_one with can.interface.Bus() as bus: AttributeError: module 'can' has no attribute 'interface'

Thanks

Darkrem1 avatar Oct 05 '22 15:10 Darkrem1

This problem could lie in your "Python Interpreter" selection in PyCharm, which could be verified by running your script from the command line.

You can run the script from the command prompt by typing python path/to/file.py and pressing enter. If you did not install Python to your path, then you will need to provide the path to your Python executable to do so. Install the python-can package to pip from the command line first. python -m pip install python-can

j-c-cook avatar Oct 05 '22 22:10 j-c-cook

Maybe you have another file named can.py or a package named can?

zariiii9003 avatar Oct 07 '22 16:10 zariiii9003

Maybe you have another file named can.py or a package named can?

I already had this happen several times on my machines ...

felixdivo avatar Nov 12 '22 01:11 felixdivo

I think we can assume it is solved by now.

felixdivo avatar Nov 12 '22 01:11 felixdivo