I'm trying to use extra_view Django package. I've installed it and in terminal it showed as successful and I added it to installed apps in setting.py. As I don't use virtual environment it's all installed globally, but when I try to import that package there is an unresolved import error. I use VS Code if it means something. It also happened with some other packages that I installed. Do you have any idea what is happening?
Can you show full traceback to this error?
And your code where you import it.
It should work fine if you do everything as it says here in the docs:
https://django-extra-views.readthedocs.io/en/latest/pages/getting-started.html
Everything is ok actually. I just restarted VS Code and then there weren't any errors anymore. Apparently VS Code was the only issue.
Related
I'm trying to run a script in python 3.9.1, on mac os, and several modules show a message of unresolved import 'aioboto3'Python(unresolved-import)
I ran pip3 in order to install them, it seems to have installed them but the messages still appear.
vscode does display correct version on the lower left bar.
Please advise on how can I resolve this? or even if this is an issue?
Based on the information you provided, I reproduced the problem:
Please check whether the module "aioboto3" has been installed in the python environment you are using: (pip show aioboto3)
(If it does not display the module installation information, it means that the module is not available in this environment. Please open a new VS Code terminal and make sure that the terminal is using the expected python environment (python --version).)
Please reload VS Code to let it recognize that the module has been installed.
Run:
Reference: Python Environments in VS Code.
I had a few imports I was using for my project. Some of these included packages I downloaded using pip like
import MySQLdb
While others were modules from within my project like
sys.path.append(os.path.join(os.path.dirname(__file__), "../")) .
from util.myFile import get_mysql_connection, execute_query,
These were all working and I was able to run my application on PyCharm. I closed PyCharm and opened it back up to find most of these imports "could not be found". Any help regarding this will be much appreciated. Thanks
Update:
I'm able to run the file from terminal (iTerm) without errors. However, the file still shows red error marks by the imports. Seems like PyCharm isn't recognizing some sort of path
Check the traceback for what version of python is being called.
There could be a mismatch between the version you've imported modules with and the version that runs by default.
Double check what is being used as your project interpreter. This can change the available packages to your current project.
Found in PyCharm by going to Settings -> Project:<'Your-Project'> -> Project Interpreter
Also, did you install MySQLdb in this way? MySQLdb - ModuleNotFoundError
I am trying to use a module from github called ffn and have downloaded it to my desktop. I am using Jupyter notebook for Python and was told i need to insert this code:
import sys
sys.path.insert(0, r"C:\Users\...\Desktop\ffn-master\ffn\_core_.py")
import ffn
..in order to use this code.
However when i run the subsequent lines of code that call functions from here I still get the error:
C:\ProgramData\Anaconda3\lib\site-packages\ffn\core.py:2054:
RuntimeWarning: invalid value encountered in minimum
negative_returns = np.minimum(returns, 0.)
I restarted the kernel and everything but still get the same error.
Can anyone help?
"The desktop module has the fixes that the installed module in the anaconda path does not." - It seems like you still have the original module installed in the anaconda library.
try running
conda uninstall ffn
and then include the entire library in the path in you notebook with
sys.path.append(os.path.abspath(r"C:\Users\...\Desktop\ffn-master\ffn\")
So I know this is nearly a duplicate of this ImportError question, but I'm not sure how to use those answers to fix this problem. I installed yahoo-fin package using my conda prompt:
pip install yahoo-fin
So clearly it is installed as Eclipse seems to recognize the package and I can even use cntl-space to autocomplete and F3 to explore the package. However, when I try to run
from yahoo_fin.stock_info import get_data
I get "ImportError: No module named stock_info".
From the SE question above I checked the init.py in the directory and it definitely has the CRLF problem, but even when I use notepad++ to replace "\r\n" with "\n" I still get the same error.
What am I missing?
Are you able to load the package without using Eclipse? I would try running Python from the command line, and then typing:
from yahoo_fin.stock_info import get_data
to see if that still gives you an error. If it still gives you an error, then we know it's not an Eclipse issue. However, if it does work, then it's probably an issue with Eclipse. In that case, I would maybe look at this other post: How To Make Eclipse Pydev Plugin Recognize Newly Installed Python Modules?.
Please let me know if that helps.
When I try to import redactor.widgets in my Django app I get the error from the title. In the python command line importing redactor.widgetsdoesn't produce any errors. Does anyone have an idea as to why this is happening? Everything runs in a virtualenv, I tried installing django-redactor using pip and manually.
Thanks in advance.