How I do properly import serial data from arduino using pycharm - python

I am newbie in python.
After I installed python 3.8 latest version, libraries ...etc
Pycharm IDE, and for every time you create project you have to install packages so your code look nice with no red line under.
after I spent hours trying to find whats going on, Error, visual studio ++14 and not 15 or 19.
The code line, import serial doesn't seem recognized by pycharm or by python.
I have read many people having the same problem but few were successful to solve, other are still not.
My Problem is that I need to plot data from arduino using python over serial.
Anyone have an idea how to solve the import serial not working?
The code implemented:
import serial , error
import numpy as np package not found but managed to install it and have to install it again
import matplotlib.pyplot as plt
%matplotlib qt
ser = serial.Serial('COM4',9600) Syntax error
Just tried to install matplotlib package, I got this error
ModuleNotFoundError: No module named 'Cython'
An hour ago did work just fine downloading the package.
Any recommendation for another python IDE than pycharm ?

U can use anaconda navigator. It comes with many inbuilt libraries such as pandas numpy matlab etc according to me it is best to use anaconda navigator in which u can either use spyder ide or jyputer notebook do upvode if u found helpful

Related

VSC does not import installed python libraries

I recently got a new computer and installed VSC as well as the official python on it. I installed some extra libraries for python on it with pip but whenever I want to run a script it gives me the error: ModuleNotFoundError: No module named 'numpy', or any other library installed afterwards. The libraries that come with python do work.
When I run the same script in IDLE for example, all the libraries are found and it works fine, but I would like to be able to code in VSC.
For example:
import numpy as np
import pygame as pg
import time
Rest of the code...
The error occurs right when it tries to import the libraries.
Any ideas on what might be causing the problem?

I can't import pandas in jupyter notebook (Python 3 in anaconda)

I have Anaconda installed on my laptop. I opened my windows command prompt and went ahead with typing jupyter notebook and it opened successfully in the browser. But when I tried to type in Import pandas as pd it gave me an error message like this:
` File "<ipython-input-3-cd3275bba7c6>", line 1
Import sys
^
SyntaxError: invalid syntax`.
The Kernel is Python 3, there is no other option there.
I tried updating the Anaconda navigator and shut everything down before trying again, but it still won't work.
I suspected it had something to do with having both Python in my machine and Anaconda?
I read that other people that have the same problem tried uninstalling and installing pandas again, or changing the environment path (?). Unfortunately I am not quite sure how I do any of them as I am very new in learning Python.
Can someone give me some directions as to how this should be done?
PS: Others say that there should be only one Python, either Python or Anaconda in the machine. So which one is better and which one should be gotten rid of, if needed?
All I want is to practice Python for a udemy class I am taking and I am stuck with the problem already.

ModuleNotFoundError in Jupyter Notebook for Python 3 but not Python 2 (Mac OSX)

I'm trying to use Pandas in a Python 3 Jupyter Notebook on a Mac (OSX High Sierra 10.13.6), but I get the following error when I run import pandas as pd:
ModuleNotFoundError: No module named 'pandas'
I have the same issue with Numpy and other Python packages.
This problem does NOT occur when I try the same thing in a Python 2 Jupyter Notebook on the same system.
Please see the links to screen shots below:
Jupyter Notebook Python 3 Import Pandas Error
Jupyter Notebook Python 2 Import Pandas NO Error
Thanks in advance.
I seem to have solved my problem by installing the latest version of Anaconda, Anaconda 3. I don't know if this is the most precise or elegant solution (seems a bit like rebuilding a house to fix a broken pipe) but it worked.
If anyone has any other advice, I'm happy to hear it.
Thanks.

Mayavi has stopped working, crashes Python Jupyter notebook

I had installed Mayavi package in Anaconda Python on my Windows 7 machine. It was working until today. Today, it has stopped working, and crashes my Python Jupyter notebook. For example, the following simple script causes "Python has stopped working" message and Python kernel death:
import numpy as np
import mayavi
from mayavi import mlab
x, y, z = np.ogrid[-10:10:20j, -10:10:20j, -10:10:20j]
s = np.sin(x*y*z)/(x*y*z)
sf = mlab.pipeline.scalar_field(s)
The versions of Anaconda, Python, and Mayavi are 4.1.1, 3.5.2, and 4.5. Additionally the versions of numpy, traits, and vtk (required packages for Mayavi) 1.11.1, 4.6, and 7.0.0. I tried updating Mayavi and all these packages, and that did not resolve the issue. Can someone please help?
Apparently the issue is that Mayavi display does not work over a remote desktop connection, which is what I was working through yesterday! I have not clue why, and am curious to know if someone has an answer. I'm logged into the machine directly today, and it works.

ImportError: No module named 'matplotlib'

Brand new to Python (typically program in MSDN C#) and I'm trying to make use of the matplotlib to generate some graphics from .csv files
I've downloaded & installed Python as well as Anaconda onto my Windows 10 machine, the versions are Python 3.5.2 and Anaconda 4.1.1
I open up the Python "notepad" interface and do
import matplotlib.pyplot as plt
plt.plot([1,2,3],[3,2,1])
plt.show()
but when I run the code I get the error:
ImportError: No module named 'matplotlib'
I've looked at some other posts for this but they all seem to be in regard to Mac OSX or Linux. Some have pointed to multiple installs of matplotlib, but I haven't turned up such a situation so far. What might be causing this, or how can I troubleshoot it?
**Edit:
The path returned to me from the import sys recommended in the comments gave me this response
['C:\Users\a.watts.ISAM-NA\Desktop',
'C:\Users\a.watts.ISAM-NA\AppData\Local\Programs\Python\Python35-32\python35.zip',
'C:\Users\a.watts.ISAM-NA\AppData\Local\Programs\Python\Python35-32\DLLs',
'C:\Users\a.watts.ISAM-NA\AppData\Local\Programs\Python\Python35-32\lib',
'C:\Users\a.watts.ISAM-NA\AppData\Local\Programs\Python\Python35-32',
'C:\Users\a.watts.ISAM-NA\AppData\Local\Programs\Python\Python35-32\lib\site-packages',
'C:\Users\a.watts.ISAM-NA\AppData\Local\Programs\Python\Python35-32\lib\site-packages\setuptools-26.1.1-py3.5.egg']
You essentially have 2 versions of python on your system - the standard one you downloaded and the one that ships with Anaconda. When you are running code in the IDLE you are using the standard version (in C:\Users\a.watts.ISAM-NA\AppData\Local\Programs\Python\Python35-32\python.exe) where matplotlib isn't installed which is why you are getting the error.
You need to use the Anaconda version (C:\Users\a.watts.ISAM-NA\AppData\Local\continuum\anaconda3\python.exe) that comes with the scientific stuff already setup. It looks like your system is using this one from the cmd so if you run scripts from there it should use the Anaconda version. If you want to use something more interactive you can also use spyder - the Anaconda version of the IDLE - or run jupyter notebook from cmd to get a browser based platform for interactive development

Categories