I successfully installed Yahoo finance in Anaconda
When I type
pip list
in the Anaconda Prompt, it shows that yahoo finance is there.
But when I try to import it on Spyder, I get the error:
"No module named 'yfinance"
Basically your error message it because Spyder isn't configured to work with conda's environment.
Check this link here and the possibles solutions from it:
Installing packages into the same environment as Spyder
Spyder is a Python package just like any other you may be used to, and so you can import any package within its Console or Editor as you could from a regular Python or IPython terminal launched in Spyder's environment:
If Spyder is installed with Anaconda (as we recommend) and launched
via a shortcut, from Anaconda Navigator or from Anaconda Prompt
without modifying anything, this will be the default base Anaconda
environment.
If Spyder is installed via pip (experts only) and not into a virtualenv/venv, this will usually be whatever Python installation pip itself belongs to.
If you use a system package manager (apt-get, dnf, emerge, etc) to install Spyder, this will typically be your system Python and its library of packages.
If you installed Spyder into a specific environment (conda-env or venv), or it came with a pre-configured one (like those for Keras or TensorFlow) and launched it from there, it will only have access to packages from that environment.
Therefore, if you'd like to use a package with your existing Spyder install (e.g. import'ing it into your scripts, packages or a Spyder IPython console), the simplest way to do so is to install the package into the same environment in which you installed Spyder, typically by the same means you installed Spyder (conda, pip, package manager, etc). However, if you're installing packages with pip, conda-forge, Github, or custom channels, working on multiple major projects at once, using prebuilt environments, or otherwise have more sophisticated needs, you'll likely want to use one or more separate environments for your packages. If so, the next section explains how.
Related
I've been enrolling in JetBrains academy for almost 2 months now to learn python core and machine learning with python. I have learned how to create new virtual environments using PyCharm IDE and use pip installation to install useful packages. At some point when I was ready to learn the Machine Learning track, it was recommended to install anaconda navigator since it provides tonnes of pre-installed packages that are helpful for machine learning tasks.
PROBLEM:
However, ever since I downloaded anaconda navigator, I could use pip installation in conda environment ONLY. In other virtual environments, the following error occurs: "...pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available".
SUGGESTED SOLUTIONS FOUND:
Some solution suggested that I should uninstall anaconda and python,
then re-install python to fix this. However, this method would defeat
my purpose of installing anaconda in the first place.
MY QUESTION:
How to fix this error without uninstalling anaconda?
Followings are my configurations:
PyCharm Community Edition 2022.1.1 on Windows 10
Python 3.9.10 running in a Virtual Environment (e.g. Virtualenv)
anaconda navigator 2.2.0
anaconda3 with openssl 1.1.1n and pyopenssl 21.0.0 modules installed
I actually got some idea from this link. The author added extra paths for anaconda folders with openssl into the python interpreter paths:
In the PyCharm IDE, I fixed the error with the following steps:
1.
Go to: Settings -> Project -> Python interpreter
2.
Click on the "gear symbol" and select "Show All...". This will navigate you to a "Python Interpreters" window.
3.
While your intended interpreter is highlighted, click on the "path symbol" which will navigate you to an "Interpreter Paths" window.
4.
Click "+" symbol to add path in the interpreter paths window.
5.
Add a new interpreter path as shown below. (Type where conda in anaconda prompt to find the full path to anaconda3 folder)
6.
In my case, I needed to restart my PyCharm IDE for the pip installation to finally work.
<my full path to anaconda3>
<my full path to anaconda3>\Scripts
<my full path to anaconda3>\Library\bin
NOTES:
I still wonder if this is the best method there is or is there a way to install the openssl directly into my virtual environment without redirecting my interpreter paths to the ones in anaconda folder.
Sometimes I need to checkout a specific branch of a python package from github.
Branch is checked out and I run the standard python setup.py install from the directory of the package.
This installs fine. If I open a jupyter notebook (from anaconda prompt), then the package works as expected. But when I open Spyder (from anaconda navigator), the version of the package is from the anaconda installation.
How do I get my Spyder to recognize the branch in my github folder over the conda version? I think it is to do with python path system environment variables (?), but I never managed to get this set up properly.
N.B. This is on Windows 10.
I'm trying to use VS Code for python in an Anaconda environment. I have (after some googling and travail) gotten it using my custom environment. However, pylint and the editor don't recognize the installed netifaces in the environment.
The environment (billh) is being loaded:
The errors from python are shown here:
Oddly, importing from ipython running in the built-in terminal does work:
This was newly installed today, via Anaconda. Here's the version info
It isn't that the extension can't find the netifaces package, it's that Pylint can't. Make sure that the Pylint you are having the extension run for you is installed into the same conda environment that you are running from (e.g. make sure you didn't set python.linting.pylintPath to something outside of your conda environment). Also make sure that ipython is from the same environment as well (e.g. you are using a conda environment and launched the terminal with the Python: Create Terminal command).
The Anaconda website mentions that the installer has 100 of pre-built packages. Even the installer size of 500mb hints that there should be some pre-built packages.
Yet when we want to use any of the packages we have to install them through the command eg. conda install nltk
Which basically downloads the package from internet and then installs it. Which seems counterintuitive since it is already mentioned on website that nltk is present in the installer.
Can anybody throw some light on this?
There are two parts:
Conda - Package & environment management system. This gives you the
conda command and serves a similar function as pip and
virtualenv.
Anaconda - Python package distribution containing 100's of scientific
packages that are tests and verified to work together.
If you install Miniconda, you will just get conda without the full Anaconda distribution. If you install Anaconda, you will get both the conda management system and the Python distribution. You can also get Anaconda after only having installed conda by running conda install Anaconda.
I've been using Canopy and IPython notebook especially, most of the time. I installed Python3.4 from Python.org at the very beginning. Since then every time I run my IPython notebook and if there is any packages that I am missing, I download them by using the package manager in Canopy. However, recently I started that tango with Django tutorial project and used a lot of command lines. I installed Python2.7 later, and the related packages by using pip ever since. My question is: what's the relation of Canopy package manager and pip? Because I am not afraid I might have downloaded the same packages and created unnecessary duplicates more than once by using them separately and simultaneously...Thanks
Type:
which pip
It will tell you if pip is pointing to your canopy python directory, or to your system python directory. I believe that pip will use whatever your system's default python is. You can figure this out by typing:
which python
Generally, when I put canopy on a computer, I make canopy the default python (it will prompt you the first time it starts up, and you can set it in the options later). After I do this, pip will install packages to the canopy python directory. This layout usually works best for us, because you can still use:
python setup.py install
To install packages to canopy.