Python2.6 was installed by default in my old centos server. Now I want to create a Python3 environment to install python3 specific module by conda
conda create -n py3 python=3.5.3
source activate py3
After activate the py3, I try to install hovercraft by pip3 install hovercraft, the shell tells "command not found: pip3". At first I thought pip3 was installed with Python3, but the result was not the case.
So I think I can install it manually. The package gzip file was downloaded from python package index, and install by conda install --file hovercraft-2.3.tar.gz. But it doesn't work.
Now I have two problems:
how to install pip3 for virtual-env create by conda?
Is it possible to install python package index downloaded package locally in conda?
pip3 and pip would make a difference only when you are not using any environment managers like virualenv (or) conda. Now as you are creating a conda environment which has python==3.x, pip would be equivalent to pip3.
Related
I have been advised using pip in a Anaconda virtual environment is bad. But some packages are not on conda or on conda forge.
When I run
conda activate virtualenv
where pip
I get two paths, one which is outside the environment
C:\Anaconda\virtualenv\Scripts\pip.exe
C:\Anaconda\Scripts\pip.exe
How do I fix it, so that when I do pip install package it only installs in the virtual environment?
The command line should use the first pip it finds, which in your case is the one in the virtual environment. This pip will only install packages in your environment. You can check which one is running with pip --version.
I have a device with python3.7 preinstalled, in which i have installed also python3.9. I managed to change the version I am using of python3 and now the command "python3" followed by the .py file runs with python3.9.
The problem is I tried installing pandas with pip3 but it does not work (it didn't work even in the preinstalled python3.7), so I found that in debian you can install package, for example in this case pandas, using "sudo apt-get install python3-pandas" but this command keeps installing pandas in python3.7 and not in python3.9 even if now "python3" refers to python3.9.
Has anyone ever encountered this problem and has a solution?
python3.9 -m pip install pandas
Venv
You could use a virtual environment (venv) for installing dependencies.
This venv could be project specific or global.
Run python3 -m venv .venv in your project folder to create a .venv folder, which holds the venv configuration.
Run source .venv/bin/activate to activate the venv. This will link pip3 from your python 3.9 version to the pip command.
Now you can do pip install pandas to install the pandas dependency into the venv.
Conda
Another solution would be to use Anaconda or Miniconda
https://pandas.pydata.org/pandas-docs/stable/getting_started/install.html
conda create -n name_of_my_env python
This will create a minimal environment with only Python installed in
it.
To put your self inside this environment run:
source activate name_of_my_env
On Windows the command is:
activate name_of_my_env
The final step required is to install pandas. This can be done with
the following command:
conda install pandas
Hey everyone I installed Python3.9 on my Mac using homebrew package manager but now I do not know how to install packages to it for use
Can anyone please tell me, thanks !
You should first do some research on the Python virtual environment, but the final answer to your question is to use pip install for installing Python packages. Be aware that there are other options out there, but pip is the most prevalent.
When you installed python, it has pip installed by default. pip comes with python. You can check pip version by
pip --version
OR
pip3 --version
Now, in order to install any other package, you can install by
pip install <package-name>
It would be better if you install a virtual environment, and install all other packages inside the virtual environment so that you can install packages according to your project requirements and with different versions.
To install virtual environment, do
pip install virtualenv
Once the virtual environment is installed, you can create your virtualenv according to your project requirement by:
virtualenv -p python3 venv
Here venv is your virtualenv name. To activate it,
source venv/bin/actiavte
Now, you can install all your required packages inside this virtualenv by pip3 install <package-name>. This will keep it separated from your system environment.
If I have a directory with setup.py, in pip, I can pip install . in the directory to install the package.
What if I am using conda?
conda install . makes conda to find a package named dot.
conda packages are a different structure than standard python packaging. As a result, the official, recommended and best-practice approach is to use conda to install pip within an activated conda environment, and use that to install standard packages:
conda install pip
NOTE: You want to use conda packages whenever they're available, as they have more features within a conda environment than non-conda packages.
conda install pip will install pip within the currently activated conda environment, and will ensure that it is integrated with conda so that, for example, conda list, will include any packages installed with pip.
NOTE: Commands like conda update will ignore pip installed packages, as it only checks conda channels for available updates, so they still need to be updated using pip. See this Question/Answer discussion:
Does conda update packages from pypi installed using pip install?
NOTE: See #kalefranz comment below regarding conda 4.6 experimental handling of packages.
If you're interested in creating your own conda package(s), take a look at this question/1st answer for a great run-down:
How to install my own python module (package) via conda and watch its changes
If you simply wish to install non-conda packages, using pip is the correct, and expected, way to go.
You can use pip install from within conda environment.
Just activate your environment using:
$ conda activate myenvironment
and use pip install . to install your package in environment's directory.
EDIT: As pointed by Chris Larson in another answert, you should install pip inside the environment using
$ conda install pip
in order to register packages correctly.
If I have a whl file, I can use pip install xxx.whl to install it.
From the documentation, conda install from a local file is also available, but the file should be a tarball file, i.e. .tar.bz2 files.
conda install /package-path/package-filename.tar.bz2 works. And if I have multiple tarballs, I can tar them to get a .tar file, then conda install /packages-path/packages-filename.tar installs the packages in it.
I've setup anaconda and created a python 3.3 environment. Now I wanted to install some package (dataset). The install instructions ask to clone the git repo and run
python setup.py install
but now the packages are not installed to the environments site-packages folder but to a different anaconda location.
What are the normal steps to solve that problem? Newbie-compatible solutions are preferred. The OS is MacOSX, just is case, it is relevant.
It looks like conda automatically adds pip to your conda environment, so after you source your conda environment, i.e.:
source activate ~/anaconda/envs/dataset
you should be able to install it like this:
git clone git://github.com/pudo/dataset.git
pip install ./dataset
EDIT
Here are the exact steps I took:
$ conda create -p ~/anaconda/envs/py33 python=3.3 anaconda pip
$ source activate ~/anaconda/envs/py33
$ which pip
~/anaconda/envs/py33/bin/pip
$ pip install ./dataset/