I want to install Earth Engine API on Python on Ubuntu 18.04. I have both Python 2.7 and Python 3.6 installed on my system, and I install Earth Engine using both pip and pip3 as instructed (installing google-api-python-client, oauth2client, and earthengine-api) without any problem. But I get errors on both 2.7 and 3.6:
On Python 2.7, "import ee" works but "ee.Initialize()" returns this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Initialize'
On Python 3.6, "import ee" doesn't work and return this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sshahhey/.local/lib/python3.6/site-packages/ee/__init__.py", line 1, in <module>
from .main import main
File "/home/sshahhey/.local/lib/python3.6/site-packages/ee/main.py", line 10, in <module>
import StringIO
ModuleNotFoundError: No module named 'StringIO'
Any help? I am particularly interested in solving the problem for Python 3.
Following up on Kevin's answer:
I had this same issue, but the state of my /usr/local/lib/python2.7/site-packages/ee looked the same as that of my coworker, whose Earth Engine API was working fine. The issue is that there are 2 pip packages which write to the same directory:
earthengine-api:
this is the package you want
writes the Earth Engine library to site-packages/ee
ee:
Unrelated to EE, just a wrapper for dd
writes a main.py and __init__.py to site-packages/ee
The only difference between our two setups was the order in which we installed those packages. For me, installing ee second overwrote the __init__.py file, which prevented the ee module from importing the library contents. The fix was to completely clear out the directory and related dist-info dir, and start over:
rm -rf /usr/local/lib/python2.7/site-packages/ee
rm -rf /usr/local/lib/python2.7/site-packages/earthengine_api-0.1.182.dist-info
sudo pip install earthengine_api
It looks like your system has a Python package called ee which is not the Earth Engine API. I say this because the Python 3 traceback specifies a file named ee/main.py, which does not exist and never has. This would also explain why ee.Initialize() was not found in the other case.
I'd recommend going into /home/sshahhey/.local/lib/python3.6/site-packages/ee/ and browsing the code there to see what other package it might be. If it's not something you need, then you can just delete that ee/. If it is something you need for another purpose, you can use virtualenv to manage installations of conflicting libraries.
Related
I have been experimenting with PyInstaller for a few days. My operating system is FreeBSD 10.4 and I use Python 3.6. When I issue this command from the terminal, it works all fine:
# pyinstaller my_script.py
But this command has an unprecedented side effect. When I write this:
if __debug__:
print("debug")
I get "debug" printed to the console, which suggests that PyInstaller compiles the script with debug symbols.
While searching for a solution to this problem, I found that running PyInstaller through the Python interpreter with the -O parameter would solve the problem:
[root#bsd-pwb ~]# /usr/local/bin/python3.6 /usr/local/lib/python3.6/site-packages/PyInstaller/__main__.py my_script.py
But this time, I get this:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/PyInstaller/__main__.py", line 21, in <module>
from . import __version__
ImportError: cannot import name '__version__'
What am I doing wrong here? How can I get PyInstaller to compile with "debug" set to "False"?
I recommend you trying your script exactly as it is but using a Python 3.5 Enviroment, there are so many publications where you can realize that pyinstaller is more stable with python 3.5 versions than 3.6. I had several errors as the one you are commenting and at the end they get solved just running my scripts on python<=3.5
From the docs you can actually get it working by using another method: set explicitely the PYTHONOPTIMIZE environment variable to a non-zero value, in your case:
PYTHONOPTIMIZE=1 pyinstaller myscript.py
I am working on windows platform and have set up all my requirements for NSGA2 solver but still it is not working. I have downloaded and installed MPI, MinGW, SWIG, Pyopt, pyoptsparse but still I am unable to use the pyoptsparse driver.
If someone could help on this, it will be of a great help. Thanks
I have pasted the error below
D:\Anaconda2\Scripts\python.exe D:/OpenMDAO/Mitul/Sellar/Sellar_MDF.py
Traceback (most recent call last):
File "D:/OpenMDAO/Mitul/Sellar/Sellar_MDF.py", line 6, in <module>
from openmdao.drivers.pyoptsparse_driver import pyOptSparseDriver
File "d:\anaconda2\lib\site-packages\openmdao\drivers\pyoptsparse_driver.py", line 19, in <module>
from openmdao.core.driver import Driver
File "d:\anaconda2\lib\site-packages\openmdao\core\driver.py", line 15, in <module>
from openmdao.util.options import OptionsDictionary
ImportError: No module named options
it is difficult to get MPI and pyopt-sparse built correctly on windows. But It has been done successfully. You can see the docs here for detailed instructions
That being said... there is clearly something wrong with your OpenMDAO installation. That error implies that things are not being copied correctly into the installation folder. Since you're using anaconda, I suggest that you create a new anaconda env as follows:
conda create --name om2 python=2 numpy scipy matplotlib
then activate it with source activate om2 and try to re-install openmdao via pip. You can get the very latest by doing
pip install git+http://github.com/OpenMDAO/OpenMDAO.git#master
Once you've done that, before you try to get mpi/petsc/pyopt-sparse installed you should run our test suite. Follow our docs on that, and if the tests all pass you can move on to the other more advanced install steps.
I have installed requests on my mac, but the error message says the library does not exist. I have included "import requests" on line one of my Python script. I am using Python 3 for the call because it supports Server Name Indication, which I guess I need for this? Any pointers/help is greatly appreciated!
As you can see, I have installed requests:
Daves-MacBook-Pro:documents Dave$ pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in /Library/Python/2.7/site-packages
Cleaning up...
However when I try to run my script I get this error message:
Daves-MacBook-Pro:documents Dave$ python3 perka_call.py
Traceback (most recent call last):
File "perka_call.py", line 1, in
import requests
ImportError: No module named 'requests'
Try installing requests module for Python3. You have installed it for Python2.7
This might do the job.
pip install --target='/usr/lib/python3.4/' requests
I am assuming you are using python3.4
Though splinter is installed on my Windows Vista, spyder gives an error when I import it.
When I import in windows command prompt, it successfully imports & also shows path to the init file.
Have added explicit path in PYTHONPATH Manager of Spyder and Updated module list. Yet, did not help.
Have checked my PATH environment variable. It contains the path to Python, Python/Scripts & Python/Lib/site-packages. PATH contains no spaces and PATH is indeed named as PATH & not as Path (probably thats why able to import successfully via command prompt)
When I try to install splinter again (just to confirm if it exists or not), pip says it already exists. When I try to upgrade, pip says it is already up-to-date
Have read lots & lots of articles on stackoverflow & across the web, but no solution helped.
Spyder recognizes other packages like os, numpy, etc.
Had run this code successfully on a temporary testing machine. Now trying to run on my system and its failing with error ImportError: No module named 'splinter'
Python ver. 3.4; Spyder ver. 3.4
Hoping for a solution...
Complete trackeback:
runfile('E:/Rampy/DS/Python/Code/AGMARK.py', wdir='E:/Rampy/DS/Python/Code')
Traceback (most recent call last):
File "", line 1, in
runfile('E:/Rampy/DS/Python/Code/AGMARK.py', wdir='E:/Rampy/DS/Python/Code')
File "C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\lib\site->packages\spyderlib\widgets\externalshell\sitecustomize.py", line 580, in runfile
execfile(filename, namespace)
File "C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\lib\site->packages\spyderlib\widgets\externalshell\sitecustomize.py", line 48, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "E:/Rampy/DS/Python/Code/AGMARK.py", line 8, in
from splinter import Browser
ImportError: No module named 'splinter'
Okay. So, I could make it work with a work-around.
Inspite of adding C:\Python34 & its Lib (site-packages) folder to PATH environment variable and Spyder's Python Path Manager, it failed to recognize splinter package while running the code in Spyder. So, I copied & pasted Splinter (followed by Selenium) package-folders from C:\Python34\Lib\site-packages (location where PIP installed the packages) to C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\Lib\site-packages (Anaconda's package location which alone Spyder seems to recognize) and boom! It started working!
After hearing Peter Wang talk about the Bokeh plotting environment, I had to try it. The problem is I can't even get the examples to work because I can't get the plot server going. I verified the install of all listed dependencies, and installed continuumweb (a module that is curiously absent from the list of dependencies in the Bokeh README on github). However, I still encountered the error below. It looks like this should come out of continuumweb, but I find no trace of such a sub-module within the repo. Am I looking in the wrong place? (I have not found any other instances of this exception.)
If anyone could provide some guidance, I would be grateful...
choct155#choct155-U46E:~/analysis/anaconda/pkgs/Bokeh$ python runserver.py
Traceback (most recent call last):
File "runserver.py", line 3, in <module>
from bokeh.server import start
File "/home/choct155/analysis/anaconda/pkgs/Bokeh/bokeh/server/start.py", line 76, in <module>
import services
File "/home/choct155/analysis/anaconda/pkgs/Bokeh/bokeh/server/services.py", line 4, in <module>
from continuumweb.launch_process import ManagedProcess
ImportError: No module named launch_process
Exception KeyError: KeyError(139639237560272,) in <module 'threading' from '/home/choct155/analysis/anaconda/lib/python2.7/threading.pyc'> ignored
For those who are reading this later, we've had two versioned releases since the original question, and they are all easy to install directly from PyPI via "pip install bokeh". If you are using Anaconda, it's even easier to install via "conda install bokeh".
For some reason, the pip installer did not perform well here. I just started from scratch by cloning the continuumweb repository and installing from source ('python setup.py install' in the cloned directory)...
All is well.