How to manually import a module in python - python

When i try to run ovirt downloads_disk_snapshot from this link i am getting error as
Traceback (most recent call last):
File "download_disk_snapshots.py", line 22, in <module>
import ovirtsdk4 as sdk
ImportError: No module named ovirtsdk4
Link is https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/download_disk_snapshots.py

This guide gives some very useful information on installing python packages.
In your case, you will have to install the oVirt Engine SDK itself before being able to run the example.
Installation instructions are given within the same Github project that you are mentioning:
https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/README.adoc#installation

Related

ModuleNotFound error even pip is already used

I am a new at Python and I have a roblem with installing one framework.
https://github.com/zalando/connexion
I have already used the command in the terminal 'pip install connexion'
But still when I try to start a programm I get such error:
PS C:\Users\fele\OneDrive\Desktop\Python\Uebergabe\pYTHON_BACKEND_2020_03_12> & "C:/Program Files (x86)/Python37-32/python.exe" "c:/Users/fele/OneDrive/Desktop/Python/Uebergabe/pYTHON_BACKEND_2020_03_12/test_local/test_local_application_hook.py"
Traceback (most recent call last):
File "c:/Users/fele/OneDrive/Desktop/Python/Uebergabe/pYTHON_BACKEND_2020_03_12/test_local/test_local_application_hook.py", line 9, in <module>
from cwsm import connexion_manager
ModuleNotFoundError: No module named 'cwsm'
Cannot anybody give me a suggestion why is it happening?
Thanks in advance
The github page shows:
import connexion
So your import is wrong, try using connexion.
Source:
https://github.com/zalando/connexion#running-it

How to properly install csdtoolbox-remote?

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.

codeanywhere.com Python doesn't see virtualenv

I use codeanywhere.com try to create application with Python werkzeug and jinja2.
I install those library utilize virtualenv. Now I face the problem
Traceback (most recent call last):
File "manage.py", line 4, in
from werkzeug import Request
ImportError: No module named 'werkzeug'
virtualenv activated but nothing is works.
Does anybody has experience with codeanywhere.com?
Oh I solve this problem. In the container config file add instruction "source venv3/bin/activate" as shown on a picture add path to python as well.
enter image description here

Installed Twitter module for python cannot be imported

$ python3 setup-py install
....
Installed /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/twitter-1.17.1-py3.5.egg
Processing dependencies for twitter==1.17.1
Finished processing dependencies for twitter==1.17.1
$ python3 twitter.py
Traceback (most recent call last):
File "twitter.py", line 1, in <module>
from twitter import Twitter
File "/Users/eddiee/2_python/twitter.py", line 1, in <module>
from twitter import Twitter
ImportError: cannot import name 'Twitter'
What might cause the problem:
Due to the restrictions of the preinstalled python on Mac, I installed another new python and changed the path. But I don't know how to install the module to the new python.
Eddie:
Try to change the import line to:
import twitter
or:
from twitter import Twitter
Hope it helps.
The problem here is I names my file as "twitter.py". When I imported the twitter module, python automatically imported the file itself, because the current file has a higher priority over the module. Simply changing the file name can solve the problem.

installing and using python-oauth2

I installed oauth2:
$ pip install oauth2
But running the python-oauth2/example/client.py returns:
Traceback (most recent call last):
File "client.py", line 31, in <module>
import oauth.oauth as oauth
ImportError: No module named oauth.oauth
I tested pip freeze:
oauth2==1.5.211
Thanks in advance
As it turns out, the example directory in the oauth2 package should be ignored. It is broken code as far as the package is concerned.
See these issues for examples of other people discovering this:
https://github.com/simplegeo/python-oauth2/issues/33
https://github.com/simplegeo/python-oauth2/issues/12
https://github.com/simplegeo/python-oauth2/pull/64
The last one is a pull request that includes new examples to use instead.

Categories

Resources