Today I tried to use new version of Python (3.6). I installed aiopg by pip (via PyCharm interpreter section tool).
And after I tried to import aiopg, exception was happend:
from aiopg.sa import create_engine
File "C:\Python36\lib\site-packages\aiopg\__init__.py", line 5, in <module>
from .connection import connect, Connection, TIMEOUT as DEFAULT_TIMEOUT
File "C:\Python36\lib\site-packages\aiopg\connection.py", line 4, in <module>
import fcntl
ModuleNotFoundError: No module named 'fcntl'
What is fcntl? It's linux python native module? In any case it does not work. Any solutions?
aiopg==0.11 has a regression but brand new aiopg==0.12 should work on Windows.
Related
Working on code that SSH's into terminal on an external device. This morning the code was able to do so. Then I updated Windows because I had put it off for a while. This was the only thing I did that I could think of may have had an effect.
I now run into a ModuleNotFoundError.
I tried updating pip, uninstalling and reinstalling ssh2-python. I changed python37 folder to read/write. Tried locating the module in python37/Lib/site-packages but not really sure what I'm looking for
SSH's into address' terminal
import socket
from ssh2.session import Session
Expected:
input for ip address
Result:
Traceback (most recent call last):
File "C:/Users/louis/Desktop/ssh2.py", line 4, in <module>
from ssh2.session import Session
File "C:\Users\louis\Desktop\ssh2.py", line 4, in <module>
from ssh2.session import Session
ModuleNotFoundError: No module named 'ssh2.session'; 'ssh2' is not a package
I had named a file in the same directory ssh2. Python loaded that instead of the module. Simply renamed the file to anything else and python was able to find the ssh2 module.
I am trying to write a server using twisted on python.
This is the head of my file :
from twisted.internet.protocol import Factory, Protocol
from twisted.internet.endpoints import TCP4ServerEndpoint
from twisted.internet import reactor
The first and the last import work perfectly. I get an error when trying to run the second import with the following traceback :
Traceback (most recent call last):
File "<ipython-input-1-c0d6286e105b>", line 1, in <module>
from twisted.internet.endpoints import TCP4ServerEndpoint
File "C:\Anaconda3\lib\site-packages\twisted-15.5.0-py3.4.egg\twisted\internet\endpoints.py", line 34, in <module>
from twisted.internet.stdio import StandardIO, PipeAddress
File "C:\Anaconda3\lib\site-packages\twisted-15.5.0-py3.4.egg\twisted\internet\stdio.py", line 30, in <module>
from twisted.internet import _win32stdio
ImportError: cannot import name '_win32stdio'
I've already tried solutions like installing pypiwin32 both manually (using whl file) and with pip install. But the problem is not solved.
I am working on windows 7 (yes !) with python 3.4.3 and Twisted 15.0
Thank you for your help.
You are using Python 3, and _win32stdio is not ported to Python 3. If you want the full set of Twisted functionality, you have to run Python 2 (PyPy 4.x+ recommended) for now.
You could install twisted-win with:
pip install twisted-win
From description:
Windows compatibility for Twisted, specifically for Scrapy
It works for me for win 7, python 3.5.2.
I want to write the Ethernet packets capture while using python.
I googling and found that I should using Pcap library or PyShark but I try to import pcap, it said that can not found module name Pcap, so I try to using PyShark instance but it show like this on Python shell
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pyshark
File "D:\Python27\lib\site-packages\pyshark-0.3.3-py2.7.egg\pyshark\__init__.py", line 1, in <module>
from pyshark.capture.live_capture import LiveCapture
File "D:\Python27\lib\site-packages\pyshark-0.3.3-py2.7.egg\pyshark\capture\live_capture.py", line 1, in <module>
from pyshark.capture.capture import Capture
File "D:\Python27\lib\site-packages\pyshark-0.3.3-py2.7.egg\pyshark\capture\capture.py", line 7, in <module>
import trollius as asyncio
ImportError: No module named trollius
About this problem, what should I do?
How can I import the library to python?
OS is Windows 8.1 and Python version 2.7.9
The pyshark project requires that trollius is installed for Python versions before Python 3.4. You'll need to install that separately.
It should have been installed when you installed the pyshark package however. Make sure to always use a tool like pip to install your packages and dependencies like these are taken care of automatically; the pyshark project declares the dependencies correctly:
install_requires=['lxml', 'py', 'trollius', 'logbook'],
Hi i have installed WAMP server(Mysql , apache ,php) and also installed "Python" separately.Now i am trying to connect to that database using python code .
This is my python code:
#!C:\Python32\python.exe
import sys
import os
import cgi
import MySQLdb
import cgitb
import SecureDb
cgitb.enable()
print ("Content-type: text/plain\n\n");
conn= MySQLdb.connect(host = SecureDb.host ,user =SecureDb.user ,passwd=SecureDb.password ,db=SecureDb.database)
cursor=conn.cursor()
cursor.execute("select * from register where Name='Subburaj'")
result=cursor.fetchall()
cursor.close()
conn.close()
But this is showing an error:
Traceback (most recent call last):
File "C:\Users\Ponmani\Desktop\test.cgi", line 5, in <module>
import MySQLdb
File "C:\Python32\lib\site-packages\MySQLdb\__init__.py", line 17, in <module>
from release import __version__, version_info, __author__
ImportError: No module named release
If anybody came across this problem please help me to solve this.Thanks in advance.
MYSQLdb doesn't come with python. It seems that you have to install it first from here. There's an executable here, if you are using windows 32. But it's for python 2.7. If you are using python 3.2 it gets more difficult. Here's an unofficial package that should work for 3.2.
EDIT:
Release module should be a part of mysqldb, my only guess is theres is still something wrong with the installation. Maybe subforlders weren't extracted correctly.You should try to reinstall.
EDIT: you can also check if you have release.py in the mysqldb directory. if you dont it is surely installation problem.
You Need to install MySQLdb Module
easy_install MySQL-python
Without any code changing, my django app started throwing an exception while loading the WSGI script. I'm using django 1.3 with python 2.7, and the top-level .wsgi is essentially unmodified from the default:
import os
import sys
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'api.settings'
application = WSGIHandler()
It started producing these errors on any request, as reported by Apache:
mod_wsgi (pid=3283): Target WSGI script '/home/beder/webapps/api/api.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=3283): Exception occurred processing WSGI script '/home/beder/webapps/api/api.wsgi'.
Traceback (most recent call last):
File "/home/beder/webapps/api/api.wsgi", line 4, in <module>
from django.core.handlers.wsgi import WSGIHandler
File "/home/beder/webapps/api/lib/python2.7/django/core/handlers/wsgi.py", line 10, in <module>
from django import http
File "/home/beder/webapps/api/lib/python2.7/django/http/__init__.py", line 122, in <module>
from django.utils.http import cookie_date
File "/home/beder/webapps/api/lib/python2.7/django/utils/http.py", line 7, in <module>
from email.Utils import formatdate
File "/usr/local/lib/python2.7/email/__init__.py", line 79, in __getattr__
__import__(self.__name__)
File "/usr/local/lib/python2.7/email/utils.py", line 27, in <module>
import random
File "/usr/local/lib/python2.7/random.py", line 47, in <module>
from os import urandom as _urandom
ImportError: cannot import name urandom
I restarted the server, and it now works normally (no errors). I'm at a loss for what to do - I want to make sure this doesn't happen again, but it's not happening now, and I have no idea why that import error appeared.
Are you executing Django inside a virtualenv? Did you updated or upgraded your system? If so and you upgraded to Python 2.7 from Python 2.6 for example you need to regenerate the virtualenv:
$ virtualenv [your-options] [your-django-project-directory]
For anyone using webfaction like Jesse and myself to run his django app but is not using virtualenv, it can happen that after the upgrade, the custom apache installation for the webapp was never restarted. This means that the stdlib changed but apache still uses python 2.7.2 because its the version it has loaded into memory.
The solution in this case is simple: login to your account via ssh and execute:
[username#webXX ~]$ ~/webapps/<webapp-name>/apache2/bin/restart
This restarts the web server and causes apache to reload the new interpreter binary.
I also found the same error when I updated Python 2.6.5 to 2.6.8, building from source. I also had built mod_wsgi from source, and initially forgot to recompile mod_wsgi for the new version of Python, and that led to the same error concerning urandom.