Starting from a new directory, I clone the following repository:
https://github.com/deribit/deribit-api-python
I rename the cloned directory to deribit_api_python
In the base directory, I then have a one line Python file:
from deribit_api_python import RestClient
This results in:
Traceback (most recent call last):
File "my_code.py", line 1, in <module>
from deribit_api_python import RestClient
ImportError: cannot import name 'RestClient'
Why does my code generate an error?
in __init__.py file write
from .deribit_api import RestClient
or you need to change intial calling by
from deribit_api_python.derbit_api import RestClient
The best way to implement the package would be to install via pip as mentioned in the repository. pip install deribit-api and then import it via from deribit_api import RestClient
Related
I git cloned a project from remote git repository into a temporary directory:
/data3/min/temp/kbmb/
I created a virtual environment 'my-env' and installed it in this environment. There is a test file in this project so I ran it under kbmb/:
python nlu/tests/random_test.py
It reported an error:
Traceback (most recent call last):
File "nlu/tests/random_test.py", line 1, in <module>
import nlu
File "/data3/min/kbmb/nlu/__init__.py", line 1, in <module>
...
This part of the error is that it didn't find the correct root:
/data3/min/kbmb/
As you can see, the 'temp' directory is missing from the path in the error message. I cloned the project into the temp directory and everything should be in the temp/ directory.
What might cause this?
It seems that in your script "nlu/tests/random_test.py" the first line is trying to import nlu
If you include this before the import nlu:
import sys
sys.paht.append('/data3/min/temp/kbmb/')
then the import nlu line should work.
I'm getting the next error while running the example python script of azure cosmos db:
Traceback (most recent call last):
File "CosmosGetStarted.py", line 1, in <module>
import azure.cosmos.cosmos_client as cosmos_client
ImportError: No module named azure.cosmos.cosmos_client
I was trying to do everything according to the next manual:
https://learn.microsoft.com/en-us/azure/cosmos-db/create-sql-api-python
Install the latest azure-cosmos package:
pip3 install --upgrade azure-cosmos
and then import the package like this:
from azure.cosmos import exceptions, CosmosClient, PartitionKey
there are more details in the official package page here
I was able to fix this issue:
Just call "python3.6 CosmosGetStarted.py" and not "python CosmosGetStarted.py"
I had an Import err that says "No module named util", but i cant find any package named util.
what path should I append in?
Code from LSTNet tensorflow by fabdline.
https://github.com/fbadine/LSTNet
# Path appended in order to import from util
import sys
#sys.path.append("..")
sys.path.append('../') #?what path should I Append?
import os
from util.model_util import LoadModel, SaveModel, SaveResults, SaveHistory
from util.Msglog import LogInit
Traceback (most recent call last): File "main.py", line 19, in
from util.model_util import LoadModel, SaveModel, SaveResults, SaveHistory ModuleNotFoundError: No module named 'util'
Follow the install instructions from the link you posted.
Under Installation it's stated:
Clone this prerequisite repository:
git clone https://github.com/fbadine/util.git
All the files you need can be found at https://github.com/fbadine/util
I have created a separate file to hold some custom issue classes for my Python file and upon execution of the following command: coverage run test_syntax.py it prints out the following error as seen in this Travis CI build:
Traceback (most recent call last):
File "test_syntax.py", line 9, in
from ros import main as s
File "/home/travis/build/Richienb/ROS-Code/src/ros/main.py", line 57, in
from errors import ConversionError, WrongInput, UnexpectedError
ModuleNotFoundError: No module named 'errors'
You can find all of the code here
Also, I have already cd into the src directory.
You need a relative import like this (second one was needed on my machine to even get to the error you have posted):
# in main.py
from .errors import ...
# ros.py
from . import errors
Python beginner here, this question was already asked here, but with no conclusive solution.
I have one file called test.py that is saved on /home/pi, I import firebase package as follows:
from firebase import firebase
I created another file called test2.py on the same path, tried to import fireabse with the same line of code as above and got this error:
Traceback (most recent call last): File "/home/pi/test2.py", line 1,
in
from firebase import firebase ImportError: No module named 'firebase'
I am using Python 2.7.9 on Linux
How can it be resolved?