I am having a problem with "import "serial".
I am running Python 3.3.2 on Windows (XP) and have installed pyserial 2.5 from the Windows installer pyserial-2.5.win32.exe. The traceback below shows what happens.
C:\hal\Python>python
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python33\lib\site-packages\serial\__init__.py", line 19, in <module>
from serialwin32 import *
ImportError: No module named 'serialwin32'
>>>
The python interpreter finds and runs c:\python33\lib\site-packages\serial\ __init__.py, which checks the os name, finds that it is "nt" and executes "from serialwin32 import *". That fails.
The file serialwin32.py is in the \serial directory with __init__.py.
I tried this with Python 3.1.1 and 3.2.3 and got the same results.
I read that pyserial 2.5 is not dependent on pywin32 but I have it installed anyway; win32, build 18, for Python 3.3.
Has anyone seen this problem or know what I may be doing wrong?
Thanks
Related
I have some issues with Anaconda3 on windows 10 64bit
Installing version Anaconda3-2019.07-Windows-x86_64 and launching python on the command line (anaconda prompt) the following message appears :
(base) C:\>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
It's actually a 64bit version but the message above displays " Anaconda, Inc. on win32". which is strange...
And then, when the ssl module is imported the following error appears :
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\u00178980\anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: %1 not a valid Win32 application.
It seems that there is some mixing out of 64 and 32 bit versions?
I am trying to learn about the urllib module in python 3.6 in windows
i am able to install the module and run the code using the python application but when i run python from command at the code's location it errors and says the module isnt intalled. I have searched for all python.exe files on my PC and there is only 1.
c:\Python36\Scripts>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>>
>>> ^Z
c:\Python36\Scripts>
c:\Python36\Scripts>cd c:\Python36\Juggles\
c:\Python36\Juggles>python urllib.py
Traceback (most recent call last):
File "urllib.py", line 1, in <module>
import urllib.request
File "c:\Python36\Juggles\urllib.py", line 1, in <module>
import urllib.request
ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not a
package
c:\Python36\Juggles>
c:\Python36\Juggles>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python36\Juggles\urllib.py", line 1, in <module>
import urllib.request
ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not a
package
>>>
>>>
>>> import urllib.request
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python36\Juggles\urllib.py", line 1, in <module>
import urllib.request
ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not a
package
>>>
>>> x = urllib.request.urlopen('https://www.google.com')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
>>>
>>> print(x.read())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
>>>
Basically i installed the module using pip in the cmd > python pip.exe install..
Then i checked using import urllib and there were no errors
Then i went to the location of the code using cd and ran python urllib.py
and it says the module isnt installed.
Then i went into python again and it says the module isnt intalled.
But it was before... where did it go?
what am i doing wrong?
i also tried the -m option as suggested below but i get this error
c:\Python36\Scripts>python -m pip install urllib
Collecting urllib
Using cached urllib-1.21.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\butte\AppData\Local\Temp\pip-build-
ejdu38tm\urllib\setup.py", line 191
s.connect((base64.b64decode(rip), 017620))
^
SyntaxError: invalid token
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\Juggles\AppData\Local\Temp\pip-build-ejdu38tm\urllib\
It is trying to do something in c:\users which isnt where the python.exe should be running from, which made me wonder if there was another version somewhere i cant seem to locate
I also just tried with elevated cmd from a new window (i always open cmd as admin) and get the same error below
C:\windows\system32>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> import urllib.request
c:\Python36\Juggles>python urllib.py
Traceback (most recent call last):
File "urllib.py", line 1, in <module>
import urllib.request
File "c:\Python36\Juggles\urllib.py", line 1, in <module>
import urllib.request
ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not a
package
Try python -m pip install package
There are two points to make in order to answer your question:
1. The urllib package you installed is a fake
The package you tried to install was a maliciously created python package that was designed to look like a real package (in this case urllib3). When installed, the package tried to send some basic information about the system on which you installed the package to a URL (you can see more details on this here). You can read more about this fake package at either of the following links:
https://app.threatconnect.com/auth/incident/incident.xhtml?incident=5256822&owner=Common%20Community (you can sign up for a free account to view this one)
http://www.nbu.gov.sk/skcsirt-sa-20170909-pypi/index.html
Sending basic information about your systems to an unknown source isn't the worst thing you could do, but is certainly something you want to avoid when possible.
2. To properly install a package...
Specifically urllib:
To install urllib, you need to specify the version of urllib you would like to install. For example, pip install urllib3 or pip install urllib2.
Any package in general:
One helpful tool is the pip search <package-name> feature which lets you view the available packages that match a given name. This is not perfect, however, as it may list malicious libraries like the one you had installed. A good guideline is that you should follow the installation instructions in a package's documentation closely to avoid any unforeseen issues. This is just an unfortunate necessity of living in a world where people make pretend python packages.
So the issue is that apparently Django uses the sqlite3 that is included with python, I have sqlite3 on my computer and it works fine on its own. I have tried many things to fix this and have not found a solution yet.
Please let me know how I can fix this issue so that I can use Django on my computer.
:~$ python
Python 3.5.2 (default, Nov 6 2016, 14:10:16)
[GCC 6.2.0 20161005] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
>>> exit()
I figured out that this error was caused by me changing my python path to 3.5 from the default of 2.7.
I've been trying to run a colleague's script and though I have pandas running now, tkinter fails to load for some reason:
D:\>python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\tkinter\__init__.py", line 36, in <module>
from tkinter import _fix
File "C:\Python34\lib\tkinter\_fix.py", line 65, in <module>
import _tkinter
ImportError: DLL load failed: %1 is not a valid Win32 application.
I was under the impression tkinter shipped with Python 3.4?
My computer is a 64-bit machine running Windows 7 if that makes a difference?
Why is this happening:
$ python3
Python 3.1.2 (release31-maint, Dec 9 2011, 20:50:50)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named argparse
I installed python3 precisely because I wanted to use argparse, which was new in 2.7, and the default version on Ubuntu Server 10.04 is 2.6.
Another thing I've noticed: Mint 10 comes with python 2.6.6, which does include argparse, and the exact version that ships with ubuntu-server 10.04 is 2.6.5 which does not have argparse. Also, I've noticed that on my Ubuntu 12.04 machine python3 is 3.2.3 and this does come with argparse. Why would this module not be included with 3.1.x???
Although argparse only made it into the standard lib on Python 2.7 and Python 3.2, for older/other versions you can still get it from pypi.
Keep in mind though that this version may not include all the updates that happened since the merge of argparse to the standard lib (as it's explained on the original project's webpage).