How to properly install csdtoolbox-remote? - python

I am having trouble installing the cdstoolbox-remote on my Linux machine (tried both Ubuntu and Debian). I installed it using pip:
pip install cdstoolbox-remote
Which successfully installs the module, but I can't import the module in Python. Importing the module causes the following error:
>>> import cdstoolbox
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/an/miniconda2/envs/tools/lib/python3.7/site-packages/cdstoolbox/__init__.py",
line 8, in <module>
with open(__main__.__file__) as f:
AttributeError: module '__main__' has no attribute '__file__'
What can be done to get it working?

Do you really need cdstoolbox-remote? The standard API for downloading data from CDS would be cdsapi, which can be installed using
pip install cdsapi
or using conda (https://anaconda.org/conda-forge/cdsapi)
I also just tried installing cdstoolbox-remote and got the same problem. But as it is flagged as experimental I even consider it to be possible that the current version is not a stable version.
And cdsapi seems to work.

Actually, the CDSAPI can also be used to execute workflows as follows:
import cdsapi
c = cdsapi.Client()
with open("workflow.py") as f:
code = f.read()
r = c.workflow(code)
print(c.download(r))
For more, read this thread on the Copernicus services documentation.

Related

Problem using installed packages with PIP (possibly due to two Python versions)

When I try to use installed packages in Python, I nearly always run into the same error.
So I e.g. install a package like this: pip3 install mathplot and when I afterwards want to use it in Python3 (I use python3 in the command prompt), I run into the ModuleNotFoundError:
>>> import mathplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mathplot'
But when I run just python, the module is found and ready to use.
Any idea where this problem comes from and how I can get rid of it?
Thanks in advance

RPy2 cannot import _rinterface_capi

I haven't used RPy2 for a number of years (and then I only played around a bit). However, I now want to start using Python and R a bit more seriously and decided to re-explore the RPy2 library.
I'm using a Mac running El Capitan. I created a new virtual environment (called env34) using Python 3.4.4 and installed the latest version of pip (19.1.1) using get-pip.py. I then pip installed numpy, pandas and jupyter into the activated environment. I also pip installed RPy2 (but had to include a trusted-host flag):
(env34) $ pip install rpy2 --trusted-host=https://pypi.org/simple/cffi
I also installed the latest version of R (3.6.0) in the default location in Applications folder and edited .bash_profile to create a RHOME environment variable by adding the following:
RHOME="/Library/Frameworks/R.framework/Resources"
export RHOME
Now when I launch Python in the virtual environment, I can import rpy2 with no problems. However, I'm trying to follow the tutorial given at http://heather.cs.ucdavis.edu/~matloff/rpy2.html and when I try to import rpy2.robjects using:
>>> from rpy2.robjects import r
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path_to_virtual_environment/env34/lib/python3.4/site-packages/rpy2/robjects/__init__.py", line 14, in <module>
import rpy2.rinterface as rinterface
File "/path_to_virtual_environment/env34/lib/python3.4/site-packages/rpy2/rinterface.py", line 5, in <module>
import rpy2.rinterface_lib._rinterface_capi as _rinterface
File "/path_to_virtual_environment/env34/lib/python3.4/site-packages/rpy2/rinterface_lib/_rinterface_capi.py", line 8, in <module>
from . import conversion
File "/path_to_virtual_environment/env34/lib/python3.4/site-packages/rpy2/rinterface_lib/conversion.py", line 8, in <module>
from . import _rinterface_capi as _rinterface
ImportError: cannot import name '_rinterface_capi'
As far as I can see, all the files referenced in the message exist in the correct locations.
Can anyone interpret this error message and perhaps offer a workaround?
Thanks in advance.

No Module After Install Package via Canopy Package Management

I need help with the pyodbc Python module. I installed it via Canopy package management, but when I try to import it, I get an error (no module named pyodbc). Why?
Here's the output from my Python interpreter:
import pyodbc
Traceback (most recent call last):
File "", line 1, in
import pyodbc
ImportError: No module named 'pyodbc
For the record: the attempted import was in a different Python installation. It is never good, and usually impossible, to use a package which was installed into one Python installation, in another Python installation.

Python third party Module global import

i'm currently into learning a bit of python and i want to import the paperclip third party module into my python file.
Yes, i already installed the pyperclip module with
pip install pyperclip.
if i create a file on my desktop, i get an error which says
Traceback (most recent call last):
File "test.py", line 1, in <module>
import pyperclip
ImportError: No module named pyperclip
However if i put the test.py in my python folder, it runs.
The question now is, is there a way to make all my installed modules available on a global scope ? I just want to have my file e.g. on my Desktop and run it without having import issues.
Thank you.
Greetings
Edit: I'm working on a Mac, maybe this leads to the problem
Found the problem.
The pip installautomatically used pip3.5 install
whereas python test.pydidn't use python3.5 test.py
Thank you #Bakurìu
Is there a way i can define python3.5as python?
You can do this :
pip3.5 install paperclip
pyperclip is install but not paperclip

Error during library import in Python (Windows)

I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.

Categories

Resources