I'm using pymongo and mongoengine.
When I do
import mongoengine
In my /home/ubuntu/project directory
I'm getting the following error:
>>> import mongoengine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/mongoengine/__init__.py", line 1, in <module>
import document
File "/Library/Python/2.7/site-packages/mongoengine/document.py", line 2, in <module>
import pymongo
File "/Library/Python/2.7/site-packages/pymongo/__init__.py", line 83, in <module>
from pymongo.collection import ReturnDocument
File "/Library/Python/2.7/site-packages/pymongo/collection.py", line 17, in <module>
import collections
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/collections.py", line 10, in <module>
from keyword import iskeyword as _iskeyword
ImportError: cannot import name iskeyword
In other directories I am able to run the import command, but not in my project directory. For example, in /home/ubuntu/ I'm getting:
>>> import mongoengine
>>>
Any clues?
****** Edit ******
There seems to be some confusion: both pymongo and mongoengine are installed using pip:
$ python
Python 2.7.10 (default, Aug 22 2015, 20:33:39)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo
>>> import mongoengine
>>>
It looks pymongo or mongoengine is not included in your default python path.
Try installing with following command
pip install pymongo
pip install mongoengine
Source For the installation documentation and further details.
Source for mongoengine Documentation.
Related
I create a new environment (my_syft env) with conda and python 3.9.7 and install syft 0.5.0.
Then I check the installation of my module and it's seem that the installations pass correctly
C:\Users\tamir>conda activate my_syft_env
(my_syft_env) C:\Users\tamir>python
Python 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import syft
>>>
>>> import sys
>>> print(sys.executable)
C:\Users\tamir\anaconda3\envs\my_syft_env\python.exe
>>>
Then in try to run and check my module in VScode and choose the current environment C:\Users\tamir\anaconda3\envs\my_syft_env\python.exe
import syft
print("hellow")
but get en error
Traceback (most recent call last):
File "c:\Users\tamir\Desktop\TAMIR\pyton vscode\federated.py", line 1, in <module>
import syft
File "C:\Users\tamir\anaconda3\lib\site-packages\syft\__init__.py", line 48, in <module>
from syft.core.node.device.device import Device # noqa: F401
File "C:\Users\tamir\anaconda3\lib\site-packages\syft\core\node\device\__init__.py", line 2, in <module>
from .client import DeviceClient
File "C:\Users\tamir\anaconda3\lib\site-packages\syft\core\node\device\client.py", line 16, in <module>
from ..common.client import Client
File "C:\Users\tamir\anaconda3\lib\site-packages\syft\core\node\common\client.py", line 18, in <module>
from ....lib import create_lib_ast
File "C:\Users\tamir\anaconda3\lib\site-packages\syft\lib\__init__.py", line 28, in <module>
from ..lib.torch import create_torch_ast
File "C:\Users\tamir\anaconda3\lib\site-packages\syft\lib\torch\__init__.py", line 12, in <module>
from . import parameter # noqa: 401
File "C:\Users\tamir\anaconda3\lib\site-packages\syft\lib\torch\parameter.py", line 9, in <module>
from ...lib.torch.tensor_util import tensor_deserializer
File "C:\Users\tamir\anaconda3\lib\site-packages\syft\lib\torch\tensor_util.py", line 2, in <module>
import pyarrow as pa
File "C:\Users\tamir\anaconda3\lib\site-packages\pyarrow\__init__.py", line 63, in <module>
import pyarrow.lib as _lib
ImportError: DLL load failed while importing lib: The specified procedure could not be found.
I dont know why there is an error.
I may be late, but to paraphrase this thread, you might have installed libboost and boost-cpp from the default conda channels. Try the following:
conda install libboost boost-cpp -c conda-forge
If on a Windows machine, make sure you have Visual C++ Redistributables 2019 or later.
See if the pip version of pyarrow works.
I'm new to Python and Cloud9, so I am not sure if I have a python issue or a Cloud9 issue (or both or something completely different)
My basic problem is that within Python I can import some modules, but not others. I've installed the modules 'xport' & 'numpy' with pip, but only 'xport' is working.
If I try to 'import numpy' i get the following error:
Python 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xport
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/polynomial.py", line 19, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/usr/lib/python2.7/dist-packages/numpy/linalg/__init__.py", line 50, in <module>
from .linalg import *
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: liblapack.so.3: cannot open shared object file: No such file or directory
>>> exit()
I've tried 'pip install numpy --upgrade', but it didn't fix anything. Where should I go from here?
Here's a URL that should help get you started in Cloud9 - get-scipy-stack-for-aws-lambda.sh. The key is to install with yum.
I can then import numpy in the Python shell and a simple Python script, but I'm having a problem getting it to work in the Lambda function itself, and it's having the same issue, unable to find the liblapack.so.3. Still working on that part. I, too, am very new to Cloud9.
I cant import rdflib in python. error detailed:
Python 2.7.3 (default, Jun 27 2012, 23:48:21)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rdflib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/rdflib/__init__.py", line 65, in <module>
from rdflib.term import URIRef, BNode, Literal, Variable
File "/usr/local/lib/python2.7/site-packages/rdflib/term.py", line 49, in <module>
from isodate import parse_time, parse_date, parse_datetime
ImportError: No module named isodate
I would be grateful if anybody can help.
Thanks.
If you actually install rdflib via pip, then its dependencies will come along with it (isodate included):
pip install -U rdflib
or
easy_install -U rdflib
Chances are you might have installed it directly from source, meaning you would have to take care of the deps yourself.
Information on installing pip if you dont have it already:
http://www.pip-installer.org/en/latest/installing.html
If you have easy_install, you can do: easy_install pip
It seems there is a dependency to isodate, so try installing that via your favorite PyPI-Installer (pip oder *easy_install*).
From command line I can't import appengine, this might be something with my python path:
$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.appengine.ext import db
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "google/appengine/ext/db/__init__.py", line 98, in <module>
from google.appengine.api import datastore
File "google/appengine/api/datastore.py", line 62, in <module>
from google.appengine.datastore import datastore_query
File "google/appengine/datastore/datastore_query.py", line 64, in <module>
from google.appengine.datastore import datastore_index
File "google/appengine/datastore/datastore_index.py", line 60, in <module>
from google.appengine.api import validation
File "google/appengine/api/validation.py", line 51, in <module>
import yaml
ImportError: No module named yaml
>>>
I don't want duplicate installations, I want to point the Python interpretor to where the missing module is. How do I make the interpretor find the app engine modules from the command prompt? In the application these imports are working.
appending:
/usr/local/google_appengine/:/usr/local/google_appengine/lib/:/usr/local/google_appengine/lib/yaml/
to your PYTHONPATH environment variable should do the trick (your SDK location may vary).
For appengine 1.9.6 google has created a new directory "yaml-3.10" that contains the yaml module. I added "[appengine install directory]/google_appengine/lib/yaml-3.10" to PYTHONPATH in my .bashrc file and that solved this problem. BTW: I use Ubuntu 14.04 LTS.
yaml is not installed in your current setup. yaml package is included with google_appengine in the lib folder. the setup.py script in the folder will add the yaml package to your current python
cd google_appengine/lib/yaml
sudo python setup.py install
I am using macports to install various modules. Generally this works well, but below is an error I am getting that I am not easily resolving:
$ python
Python 2.6.6 (r266:84292, Feb 12 2011, 16:57:53)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dns
>>> import opcode
>>> from dns import resolver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/dns/resolver.py", line 26, in <module>
import dns.message
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/dns/message.py", line 28, in <module>
import dns.opcode
ImportError: No module named opcode
Could this be a path issue?
>>> import sys
>>> sys.path
['', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']
$ cat /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/dns/init.py
[snipped comments]
# init.py for DNS class.
__version__ = '2.3.3'
import Type,Opcode,Status,Class
from Base import DnsRequest, DNSError
from Lib import DnsResult
from Base import *
from Lib import *
Error=DNSError
from lazy import *
Request = DnsRequest
Result = DnsResult
Thanks in advance.
Because you need to do:
from dns import resolver
This doesn't work:
import datetime.datetime
But this does:
from datetime import datetime
If you're importing a package that is part of another package, you need to use the "from" syntax
I uninstalled py26-dnspython and reinstalled. Problem solved. Fink on freenode made the suggestion. Thanks.
I am using Python 3.7 and I installed pubdns. This resolved my problem.
I faced extreme difficulty in using py3dns, pyDNS (won't install), dnspython and many more