On my local machine I am unable to import appengine.ext module.
I have set the path using the following code
>>> import sys
>>> sys.path.insert(1, '/usr/local/google_appengine')
>>> sys.path.insert(1, '/usr/local/google_appengine/lib/yaml/lib')
Here is the error
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.insert(1, '/usr/local/google_appengine')
>>> sys.path.insert(1, '/usr/local/google_appengine/lib/yaml/lib')
>>> from google import appengine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name appengine
>>> from google.appengine.ext import ndb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named appengine.ext
>>>
you should try to add the following code to the begining:
import dev_appserver
dev_appserver.fix_sys_path()
should work :).
Related
I am trying to import PyQt5 module in a custom python environment but it fails.
I have tested it with the system python and works fine
juan#juansphd:~/blender-2.82a-linux64/2.82/python/bin$ python3
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5.QtCore
>>>
but when I run python3 of my custom environment, it fails to load it
juan#juansphd:~/blender-2.82a-linux64/2.82/python/bin$ ./python3.7m
Python 3.7.4 (default, Oct 8 2019, 15:23:02)
[GCC 6.3.1 20170216 (Red Hat 6.3.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5'
>>>
I have tried adding /usr/lib/python3/dist-packages, where PyQt5 is installed, into the sys.path but doesnt work neither
>>> sys.path.append("/usr/lib/python3/dist-packages")
>>> import PyQt5.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.QtCore'
>>>
How should I import the module?
Running an ec2 instance on aws; when attempting to run a script that imports several packages, all packages import correctly except one: 'fuzzywuzzy' (used for fuzzy string matching). I tried installing fuzzywuzzy from source code within the virtual server but aws reacted by auto-uninstalling it.
[ec2-user#ip-172-31-39-215 BearTrap]$ python
Python 2.7.9 (default, Apr 1 2015, 18:18:03)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> import string
>>> import ast
>>> import itertools
>>> from collections import OrderedDict
>>> import fuzzywuzzy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named fuzzywuzzy
Python 2.7.5 (default, Sep 12 2013, 12:43:04)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/urllib.py", line 33, in <module>
from urlparse import urljoin as basejoin
File "/usr/local/lib/python2.7/urlparse.py", line 118, in <module>
from collections import namedtuple
File "/usr/local/lib/python2.7/collections.py", line 9, in <module>
from operator import itemgetter as _itemgetter, eq as _eq
ImportError: cannot import name itemgetter
This issue occurs when I run import urllib. Python version is 2.7. Is this a Python's version problem? Could someone tell me how to fix it?
You have a file called operator.py in the current directory, so import operator is picking up your module and not the Python standard library module operator.
You should rename your file to not conflict with Python's standard library.
I noticed that I cannot import framenet from nltk.corpus.reader or from nltk.corpus and understood that it is available in newer versions of NLTK.
$ python
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>> nltk.__version__
'3.0a2'
But the nltk.downloader shows an entry for framenet_v15 and in the filesystem I have a directory framnet_v15.
So why can I not import it?
>>> from nltk.corpus import framenet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name framenet
>>> from nltk.corpus.reader import framenet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name framenet
As you can see: framenet corpus is already installed
Example
#!/usr/bin/env python
from nltk.corpus.reader import framenet
Installation
Download NLTK 3.0
tar -xzvf ntlk-3.0a3.tar.gz
cd nltk-3.0a3/
sudo python setup.py install
Execution
./example.py
I'm trying to subclass some classes from the django-social-auth package to create custom test.
The source https://github.com/omab/django-social-auth
The problem is that i cannot import the "tests" part:
C:\Users\Alle>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import social_auth.tests.base
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tests.base
>>> import social_auth.tests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tests
>>> import social_auth.db
>>> social_auth.db
<module 'social_auth.db' from 'C:\Python26\lib\site-packages\social_auth\db\__init__.pyc'>
>>>
why i get this behaviour?
Tests aren't installed by default
from social_auth setup.py
packages=['social_auth',
'social_auth.management',
'social_auth.management.commands',
'social_auth.backends',
'social_auth.backends.contrib',
'social_auth.backends.pipeline',
'social_auth.migrations',
'social_auth.db'],