I do have a problem which many people faced already, but after searching through different solutions for hours, I still haven't solved my problem.
For a project, I need Phyton to read my Data from my arduino-uno. Therefore I need the import serial (or import pyserial, I tried both) this doesn't work. I tried installing the library (not really sure where to store it than) but that didn't help either. I also tried using "pip install pyserial" in the console, but that didn't work as well.
Whatever i do i allwas get this error:
pip install pyserial
File "", line 1
pip install pyserial
^
SyntaxError: invalid syntax
I reinstalled Python now as 2.7 and deleted everything Python related. But when i put in pip install pyserial i still geht the same Error
Could someone please help me with this?
Thanks
If you installed pyserial as you stated in the comments using the PyPI command pip install pyserial then you should use
import serial
and not import pyserial as it is shown in the documentation here
If this doesn't work, either there was a problem when installing the library, or you may not be using the same Python environment as the one you think you are (as you did not give details on how you run the script it's hard to tell).
Problem Solved!
Seems like my computer doesn't like python.
Thanks for your help
Related
I used a code snippet from stackoverflow, I can't find the post now, but this is what it was
from scapy.all import *
sniff(filter="192.168.1.25", prn=lambda x:x.sprintf("{IP:%IP.src% -> %IP.dst%\n}")
I'm getting an unexpected EOF while parsing
I don't know much about scapy, nor socket. I have no idea how to approach it. Can anyone provide a working example below? I've looked all over and was unable to find one, and this topic has been dead for years
I'm not really willing to learn socket/scapy, just want an example, something temporary, so if socket is the best, post below
this was a known Issue a year ago, try upgrading pip ,then reinstall scapy using
pip install scapy --upgrade if this doesn't cut it.
Download the developer version https://github.com/secdev/scapy/archive/master.zip you might run into different errors but this fixes you current error.
Try this:
from scapy.sendrecv import sniff
sniff(filter="192.168.1.25", prn=lambda x: x.sprintf("{IP:%IP.src% -> %IP.dst%\n}"))
The above post was correct, this was fixed ages ago. please update against the RC versions:
pip install scapy --pre --upgrade
Note: the --pre enables RC versions
First off I would like to say that I am aware that this question has been asked before, however, none of the other posts have offered a solution that resolves the problem.
I am trying to use pandas-datareader to grab stock prices from the internet. I am using windows with python version 3.6. I first installed pandas-datareader from the console using
pip install pandas-datareader.
I then wrote a code which used the line
import pandas_datareader.data as web
It came back with the error
`ModuleNotFoundError: No module named 'pandas_datareader'
I tried to redownload pandas-datareader, just in case it didn't work the first time, but the console came back with "Requirement already satisfied" so that wasn't the problem.
From there I uninstalled pandas-datareader, and reinstalled it with
pip3 install pandas-datareader
I still got the same error message.
I was worried that it might have something to do with old versions of python installed on my computer so I deleted all files for python 2.7, but this did not help the issue. I restarted spyder and my computer and this did not help. I tried Jupiter notebook and this did not help either.
Now to take my investigation one step further, I looked in my file folders at the hidden files to see where pandas-datareader could be hiding. When I go to C:\Users\J.Shepard\Anaconda3\pkgs and C:\Users\J.Shepard\Anaconda3\pkgs I see that pandas-0.23.0-py36h830ac7b_0 is installed but I cannot find anything that looks like pandas-datareader. In fact, when I search for "pandas-datareader" in my file search, I only see 2 text files with one line of code each. I do not know what to make of this discovery but I thought it might be helpful to someone else.
I hope that I have made a good case to prove that I have genuinely tried and failed to solve this problem on my own. Based on the number of other unresolved posts related to this same question, I believe that this is a question that deserves to be asked again.
I tried conda install pandas-datareader in Anaconda Prompt. It was installed and after my computer restarted, pandas-datareader worked in spyder 3.6.
I can tell many people have had issues with this but having tried all possible solutions i have made my own post which hopefully can help solve this issue specifically for me.
When i try running db.create_all() i get this error (attached in pic):
Error observed
I understand this is because mysqldb does not support python 3. But i have also tried importing the pymysql and this didnt work either (unless of course i did that step wrong? I basically added the lines:
import pymysql
and then
pymysql.install_as_MySQLdb()
into my app.py file.
I am still really new to all of this. Anybody who's had this could they explain in simple steps please?
There is a workaround to using MySQLdb package for python3. Assuming you have pip3 installed,
sudo pip3 install mysqlclient
should install the necessary packages, you can use
import MySQLdb
as usual afterwards. That's how I've installed it and have been using it since.
for some reason I want to install gmpy2 on my python(version 3.6.0), I tried it on pycharm.
and it gives me an error message like below:
(i have already installed pip), anyone help me out? thx!
Usually this sort of problem (missing header files) is related to not installing the base code package that the python code is wrapping. I don't know gmp, but I would try the suggestion here:
Where to find “gmp.h”?
After hours of research I have broken down to posting. I am trying to use the Pexpect module with python 3, which I am led to believe is possible from the document page which does say it will run with python 3.2.
Things I have tried: I have tried many different ways of installing including downloading the source and running the command sudo python3 setup.py install. I have also tried installing it with pip and *easy_install* which is what the documentation suggest. It seems that everything goes off with out a hitch until I attempt to import the module in the pyshell. When I type import pexpect I get the error:
class spawn(object):
File "/usr/local/lib/python3.2/dist-packages/pexpect/init.py", line 286, in spawn
write_to_stdout = sys.stdout.buffer.write
AttributeError: 'PseudoFile' object has no attribute 'buffer'
I have also tried googleing the error with no luck. And I have tried using python 2.7 and it works fine. I have tried on multiple debian based operating systems: Ubuntu 12.04 and Kali with the same results.
I feel like there is something obvious I am missing, but I just don't see it. Any points in the right direction Or helping me understand the error message would be much appreciated!
There was a bug in Pexpect 3.0 which stopped it working if sys.stdout was replaced before it was imported. It looks like IDLE replaces stdout, so as you've found, it doesn't work in IDLE & Python 3.
The bug has now been fixed. I'll try to get a new version of Pexpect out in the next few days, and then you'll be able to use it from IDLE.