I am trying to figure out how to install packages for the first time. I have downloaded Python 2.7 with the Anaconda distribution. When I go to terminal and I type:
pip install pandas-datareader
I see a message that the package was installed successfully. However, when I enter:
import pandas-datareader as pdr
into Spyder, I get the error:
No module named pandas-datareader
I think this might be because I am not installing the package in the right directory. I also tried:
conda install -c anaconda pandas-datareader
and got the same result. I know there are many posts about installing packages, but I am looking for a super basic beginner explanation for how to troubleshoot this. What directory should I save packages in? How do I navigate to that directory? How do I use terminal to download the package into that directory, etc.
Conda installs any package to a conda environment and pip installs python packages to any environment. Your best bet is to create an environment and conda install to that. For example,
conda create -n py35
activate py35
conda install package_name
Typing these into the command line will set up your environment, activate it, and install whatever package you want.
After following your link, I got it to work by entering
!pip install pandas-datareader
in the Spyder Ipython console!
Related
I need some help with some weird things happening in jupyter.
It all started when I was trying to install tweepy, the package was installed successfully but it doesn't work when I try to import it in jupyter and it outputs this error:
ImportError: No module named 'tweepy'
The package was installed via pip, first thing I checked was if the package was really installed in the environment or not..and it was. In short I tried the following:
I uninstalled the package with pip uninstall tweepy and then installed it again with pip install tweepy.
I then tried to install it with conda install -c conda-forge tweepy
I then tried to install it from inside the notebook with !conda install -y -c conda-forge tweepy
Well..nothing from the above did work, unfortunately. and it was getting really frustrating!
I found this post which suggest this:
import sys
!{sys.executable} -m pip install package
It did work. but here is the weird thing: whatever package I import ,even non-installed packages!, the cell just work without any errors! and when I check the list of packages installed in a totally new environment that I created to test this, which does not have any packages installed, with !conda list I get empty list as expected but still any package I import still work!
So, can anyone help me understand what just happened?
You should not use pip if you are using Anaconda. Create a virtual environment by typing: conda create -n yourenvname python=x.x anaconda where yourenvname is the name of your virtual environment and python=x.x is the version number of python you wish to use like python=3.8. Now after this activate you virtual environment. The type conda install package. And see if it works.
I am trying to install turicreate in anaconda but i unable to do it.
I tried to run a command
conda install -c derickl turicreate
but promt gives an error
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- turicreate
I also tried by run some other commands also but none of them able to installed turicreate....
can someone help ?
There is no official Conda package for Turi Create, and that user channel you are trying to install from has apparently switched to being private. Instead, follow the official directions and install from PyPI (after activating your env).
conda activate my_env
pip install turicreate
Do not install this in base env! Be aware that once you use pip install in a Conda env, the env is effectively unstable, and can no longer be managed reliably by Conda. For this reason, always install PyPI packages last or use an environment YAML file. If you know that the package has dependencies (they can usually be found in the setup.py) that are available from Conda, install those first through Conda. I strongly encourage following the best practice recommendations found in "Using Pip in a Conda Environment".
I have installed the pygal package through the following command line:
conda install -c akode pygal
However, when I search this package in the Anaconda, I can only find this package in the base (root) environment. When I try to search this pygal package in my newly created environment, nothing can I find.
Why does this happen? and is there any solution to this problem?
When you are not in an environment and run conda install , it will install it in the base. If you activate your environment then install the package using conda install, it will apply to your environment.
source activate data_visualization_coursera
conda install -c akode pygal
Or you can install a specific package to an environment using this command
conda install -n <environment_name> <package_name>
You can find all of the documentation here https://conda.io/docs/user-guide/tasks/manage-environments.html
I am using Jupyter Notebook to install packages with the command: !pip install.
I just used this command to install the Options package, but it's still not showing up. I checked the default python Environment as well as the conda environment.
list of Python environments
To install packages into jupyter notebook you have to use conda instead of pip. Just find the conda install instruction for the package you are trying to install.
For example, the command to install numpy on conda is:
conda install -c anaconda numpy
instead of the regular pip version which would've been:
pip install numpy
You can search for yours by googling: conda install <package-name-you-want-to-install>.
I need to run an older verion of PyTables, that is 2.3.1, in and Anaconda environment on Linux. But I cannot install it.
conda install -n myenv pytables=2.3.1
fails finding the appropriate version.
conda install -n myenv pytables=2
installs PyTables 2.4.0 successfully. But I need 2.3.1.
Also activating the environment and installing via pip does not work.
pip install tables==2.3.1
fails with the following error:
.. ERROR:: Could not find a local HDF5 installation.
You may need to explicitly state where your local HDF5 headers and
library can be found by setting the HDF5_DIR environment
variable or by using the --hdf5 command-line option.
Where can I find the HDF5 installation of Anaconda? And how do I pass the --hdf5 option to pip? I already tried
pip install tables==2.3.1 --install-option="--hdf5=/home/me/Programme/anaconda"
But it also fails with the same error as above.
You can try
env HDF5_DIR="/home/me/Programme/anaconda" pip install tables==2.3.1
It worked for me.
I was trying to install a completely different package with pip on a new conda environment when I got the same error.
conda install -c conda-forge pytables
This helped me to get rid of the error and successfully install the package.