I couldn't import or use tdclient library - python

I got an error with this code:
from td.client import TDClient
Error message:
ModuleNotFoundError: No module named 'tdclient'
and I installed tdclient through the command line:
pip install td-client
and it was successfully installed.

If you are using virtual environments (venv), ensure you installed the module in the right venv.
If you are indeed using the right virtual env, or you're not using virtual environments at all, there may be a typo in the import statement.

Related

Issue with Anaconda package manager - library installed, but not found in Spyder

I installed cairo using Anaconda Navigator (in case it's important, cairo is also installed in the other two environments: miniconda3 and spyder-env):
I launch Spyder from Anaconda Navigator, and try to import cairo, and get an error saying:
ModuleNotFoundError: No module named 'cairo'
Spyder seems to be using the correct python environment. If I run `conda list cairo', I get the following output:
What am I doing wrong?
I had problem similar to this with VaderSentiment analysis library. Jupyter notebook couldn't find it although it was installed. Either you can use a more stable Python version such as Python 3.7 for compatibility or you can use importlib.
conda install python=3.7
I solved it using importlib This does not answer your question "what am i doing wrong", but it solved the problem in my case. Just locate cairo.py in your Anaconda folder whatever the environment is. You can make necessary adjustments. I hope this helps if you have emergency to use that package.
import importlib.util
import sys
spec = importlib.util.spec_from_file_location("vaderSentiment", r"C:\Users\matt\Anaconda3\envs\sentiment\Lib\site-packages\vaderSentiment\vaderSentiment.py")
foo = importlib.util.module_from_spec(spec)
sys.modules["vaderSentiment"] = foo
spec.loader.exec_module(foo)

ImportError: the 'trace' from 'tensorflow.python.profiler'

I were using environments for months and they were working perfectly.. suddenly i can not execute any code in pycharm under any virtual environment and i get this error massage:
from tensorflow.python.profiler import trace
ImportError: cannot import name 'trace' from 'tensorflow.python.profiler' (C:\Users\Nuha\anaconda3\envs\tf_1.15\lib\site-packages\tensorflow_core\python\profiler_init_.py)
Any help please!!
It seams that it happens because i install more packages and maybe conflict occurs
Try to install trace
pip3 install trace
it was because environment conflict so i rebuild new environment and it works perfectly

I can execute main.py without module error in pycharm but in windows cmd I'm facing module not found error and I'm using conda interpreter

File "E:\nvn\Hacker_rank\Zoom_clone\main.py", line 4, in
from vidstream import *
ModuleNotFoundError: No module named 'vidstream'
In Pycharm by default you are with in a virtual environment and you would have already installed the specified/dependent module. But that module will only be installed into that virtualenv. So when you are running from command line that module wont be available.
So either you could point to the same virtualenv or you could create a new virtual environment and install the specific module into it and run the code.
Please let me know if it helps.

No module named 'pandas', 'mysql' despite both of the models are installed

I use VS Code as my main code editor while I'm compiling the code in multiple files it keeps giving me this error for multiple models for example
ModuleNotFoundError: No module named 'pandas'
ModuleNotFoundError: No module named 'mysql'
I reinstall these two packages using pip install pandas and pip install MySQL on my cmd but both of them give me this message requirement already satisfied which mean that both of the two libraries are installed
ps I use python 3.8.1 32-bit as my main interpreter path on VS code
how can I fix this issue?
If you are using virtual environment for your python project in the vscode, then you need to define the path of python(virtual environment) for your workspace.
So in your project, there is .vscode/setting.json where you need to add following.
{
"python.pythonPath": "/path/to/project/project_name/bin/python"
}
After that you can restart your project.

ModuleNotFoundError: No module named 'websocket' even though I installed pip install websocket

I am trying to run some code that has 'import websocket' however I am getting the error: ModuleNotFoundError: No module named 'websocket'
I have Python 3.7.3 and I am running in Spyder (if that makes a difference).
So from other questions/answers I found on here, in my cmd I ran pip install websocket and then also pip install websocket-client when the first one didn't run.
I am still getting the ModuleNotFoundError. Does it matter the location/folder of the code or where I install the pip command in cmd?
My python code starts with these import statements:
import json
import websocket
import traceback
import helper
import ssl
import time as time
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
from mpl_toolkits.mplot3d import Axes3D
In cmd I ran:
C:\Users\myname>pip install websocket
and also:
C:\Users\myname>pip install websocket-client
The error I am getting is:
File "C:/Users/micki/Downloads/Derbit-Volatility-Visulization-master/Derbit-Volatility-Visulization-master/Volatility Surface Class.py", line 2, in <module>
import websocket
ModuleNotFoundError: No module named 'websocket'
Not sure, as you did not cover how you installed and are using Spyder, though I think it is probably an issue with your environment. You might also find that you are missing the module "helper" as well. There's two easy options as follows:
If you installed and are using Spyder via conda or anaconda, follow their documentation on installing websocket-client to the correct environment found here.
The second option (the preferred option IMHO, as you can use any IDE or text editor going forward), regardless of how you installed Spyder, would be to create a python virtual environment python3 -m venv /path/to/new/virtual/environment, pip install all your dependencies in said environment, then link Spyder's interpreter to the interpereter that was installed when you made the environment. In Spyder, go to Tools -> Preferences -> Python interpreter -> check the "Use the following Python interpreter:" radio button and enter the path to the interpreter from the environment you just created. For reference, see docs on making and using a python venv here.
If the websocket and websocket-client doesn't work, try:
pip install websocket_client
This solved my issue:
sudo pip install websocket-client

Categories