I was trying to install tensorflow in a new conda environment, but I met an incompatibility issue.
First, I use conda search tensorflow-gpu -c conda-forge to search available packages, and the return is
Then, I use command conda create -n tf27 python=3.8 tensorflow-gpu=2.7.0 -c conda-forge to install version 2.7.0, but I met the error below
conda information:
You can check all available packages in anaconda by using the below code in the anaconda prompt:
conda list
To install TensorFlow in the anaconda environment:
conda install pip
#If you require the latest pip
pip install --upgrade pip
#To install current stable release of TensorFlow for CPU and GPU
pip install tensorflow
pip install tenosrflow-gpu
You can also specify the version you want to install as below:
pip install tensorflow==2.7
pip install tenosrflow-gpu==2.7
To install the latest version of TensorFlow
pip install --upgrade tensorflow
As a reference, please follow this document for installing TensorFlow in anaconda. Also check this Tested build configurations to find the compatible TensorFlow version for CPU and GPU support in your system.
I am trying to run a python file which needs numpy as an import.
I have set up an environment where numpy is installed via Anaconda. I am also using pypy, and when I try to run the file using
pypy myFile.py
I get the following error
ImportError: No module named numpy
I then run pip list to check the packages currently installed in the enivornment and numpy is there
certifi 2018.11.29
mkl-fft 1.0.10
mkl-random 1.0.2
numpy 1.15.4
pip 19.0.1
setuptools 40.8.0
wheel 0.32.3
wincertstore 0.2
I'm not sure why it is not finding numpy, any help is appreciated, thanks
If you used conda to install Numpy, you probably installed a version that is not compatible with pypy. Use pip instead. Jump into your virtual environment and:
conda uninstall numpy
pip install numpy
I have an environment created using miniconda with python 3.6.8, called basepy_3_6_8.
I want to save the environment snapshot to a file and then recreate it later on another machine:
There are different commands to capture the environment snapshot, with slightly different outputs. Which of these can I use to guarantee that the exact environment used by the user is recreated in the target?
I was hoping pip freeze > requirements.txt and pip install -r requirements.txt would work independent of the source environment, but I noticed that pip freeze from within a conda environment does not capture the python version.
Here is the code to create the conda environment, and output of different commands:
$ conda create -n myenv python=3.6.8
$ conda activate myenv
(myenv)$ pip freeze
astroid==2.1.0
autopep8==1.4.3
certifi==2018.11.29
colorama==0.4.1
isort==4.3.4
lazy-object-proxy==1.3.1
mccabe==0.6.1
pycodestyle==2.4.0
pylint==2.2.2
six==1.12.0
typed-ast==1.1.1
wincertstore==0.2
wrapt==1.11.0
(myenv)$ pip list
Package Version
----------------- ----------
astroid 2.1.0
autopep8 1.4.3
certifi 2018.11.29
colorama 0.4.1
isort 4.3.4
lazy-object-proxy 1.3.1
mccabe 0.6.1
pip 18.1
pycodestyle 2.4.0
pylint 2.2.2
setuptools 40.6.3
six 1.12.0
typed-ast 1.1.1
wheel 0.32.3
wincertstore 0.2
wrapt 1.11.0
(myenv)$ conda list
# packages in environment at C:\Users\alias\AppData\Local\Continuum\miniconda3\envs\myenv:
#
# Name Version Build Channel
certifi 2018.11.29 py36_0
pip 18.1 py36_0
python 3.6.8 h9f7ef89_0
setuptools 40.6.3 py36_0
sqlite 3.26.0 he774522_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.15.26706 h3a45250_0
wheel 0.32.3 py36_0
wincertstore 0.2 py36h7fe50ca_0
(myenv)$ conda list --export
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: win-64
certifi=2018.11.29=py36_0
pip=18.1=py36_0
python=3.6.8=h9f7ef89_0
setuptools=40.6.3=py36_0
sqlite=3.26.0=he774522_0
vc=14.1=h0510ff6_4
vs2015_runtime=14.15.26706=h3a45250_0
wheel=0.32.3=py36_0
wincertstore=0.2=py36h7fe50ca_0
I am eventually interested in a general tool that can capture the current environment of a specified type (conda, virtualenv, venv, global python environment) so as to install it uniformly on another machine. What is the best approach for this?
I've never used conda, but I'd try to use two different tools to manage the python version and your project dependencies.
To install a specific python version, I'd use pyenv: https://github.com/pyenv/pyenv.
pyenv also has a plugin to manage virtualenvs (https://github.com/pyenv/pyenv-virtualenv) that should support Anaconda and Miniconda: https://github.com/pyenv/pyenv-virtualenv#anaconda-and-miniconda
To manage your dependencies (packages you install in your virtual env), you have a few alternatives:
Pip freeze: it doesn't automatically guarantee reproducibility though, because it doesn't have a lock file to pinpoint the exact dependency tree
Poetry: https://github.com/sdispater/poetry (supports a lock file)
Pipenv: https://github.com/pypa/pipenv (supports a lock file)
Hope this is helpful.
Every time I use conda install -c some_channel to install a Python package, conda tries to update other packages from some_channel. From example, here I'm trying to install hdbscan from conda-forge, and conda wants to update ca-certificates as well.
The following NEW packages will be INSTALLED:
hdbscan: 0.8.18-py36h7eb728f_0 conda-forge
The following packages will be UPDATED:
ca-certificates: 2018.03.07-0 anaconda --> 2018.8.24-ha4d7672_0 conda-forge
certifi: 2018.8.24-py36_1 anaconda --> 2018.8.24-py36_1001 conda-forge
openssl: 1.0.2p-h1de35cc_0 anaconda --> 1.0.2p-h470a237_1 conda-forge
Proceed ([y]/n)? n
Note that conda tries to do this even if the package versions from the two channels are identical. So this is not just about upgrading to newer version.
Can I pin the channel for packages without pinning the version numbers? I wouldn't mind updating ca-certificates if the update comes from anaconda channel.
I am trying to install pytorch in Anaconda to work with Python 3.5 in Windows. Following the instructions in pytorch.org I introduced the following code in Anaconda:
pip3 install torch torchvision
But the following error came in:
Command "python setup.py egg_info" failed with error code 1 in C:\Users\sluis\AppData\Local\Temp\pip-install-qmrvz7b9\torch\
By searching on the web I found out that it may be because of setuptools being out of date but I checked and have it updated. I also tried:
conda install -c peterjc123 pytorch cuda80
But the following error arise:
The following specifications were found to be in conflict:
- pytorch
Use "conda info <package>" to see the dependencies for each package.
I also tried to load the pytorch's tar.bz2 file which I download in the following website:
anaconda.org/peterjc123/pytorch/files
And then just do:
$ conda install filename.tar.bz2
But I got the following error:
Error: HTTPError: 404 Client Error: None for url: file:///C|/Users/sluis/pytorch-0.3.1-py36_cuda80_cudnn6he774522_2.tar.bz2: file:///C|/Users/sluis/pytorch-0.3.1-py36_cuda80_cudnn6he774522_2.tar.bz2
I am quite new to this programming world so I don't really know how to dig more on the errors. Anyone knows how to get pytorch installed?
Edit: As suggested in the comments I tried:
conda install pytorch torchivsion -c pytorch
And I got the following error:
Error: Packages missing in current win-64 channels:
- pytorch
- torchvision
I did:
anaconda search -t conda torchvision
And tried to install dericlk/torchvision using the following command:
conda install -c derickl torchvision
But I am getting the same error:
Error: Package missing in current win-64 channels:
- torchvision
I couldn't find any torchvisionpackages for win-64.
conda list is giving me the following:
# packages in environment at C:\Users\aaaa\AppData\Local\Continuum\Anaconda3\envs\torchenv2:
#
mkl-include 2018.0.2 1 anaconda
certifi 2016.2.28 py35_0
cffi 1.10.0 py35_0
cmake 3.6.3 vc14_0 [vc14]
openmp 2018.0.0 intel_8 intel
mkl 2017.0.3 0
numpy 1.13.1 py35_0
pip 10.0.0 <pip>
pip 9.0.1 py35_1
pycparser 2.18 py35_0
python 3.5.4 0
pyyaml 3.12 py35_0
setuptools 36.4.0 py35_1
typing 3.6.2 py35_0
vc 14 0
vs2015_runtime 14.0.25420 0
wheel 0.29.0 py35_0
wincertstore 0.2 py35_0
zlib 1.2.11 vc14_0 [vc14]
=======
Go to the official PyTorch.org and follow the steps accordingly.
Select your preferences and you will see an appropriate command below on the page.
If you don't have GPU in the system, set CUDA as None or CPU
Example command:
conda install pytorch-cpu torchvision-cpu -c pytorch
The following worked for me. First install MKL:
conda install -c anaconda mkl
After this, install pytorch and torchvision:
conda install -c pytorch pytorch torchvision
For windows python 3.6 and above without cuda
pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
Can you please try with below steps
conda create -n pytorch_env python=3.5
source activate pytorch_env
conda install -c soumith pytorch
python
> import torch
You can even find pytorch after you execute command conda list.
For linux, cuda9.0, python3.6:
pip3 install http://download.pytorch.org/whl/cu90/torch-0.3.1-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision
For other cuda/python version: check website: https://ptorch.com/news/145.html
try updating the base conda package with the following command,then you can try reistalling it.
conda update --all
conda update -n base conda
For me it worked doing this:
Uninstall the previous version: go to C:\users\username\anaconda3 and run the anaconda-uninstall.exe
Install again anaconda
then run the following commands on the anaconda pompt:
conda create -n my_env python=2.7
conda activate my_env
start the gui app
conda install -c peterjc123 pytorch
anaconda-navigator
For Readers live in 2021/06/xx:
use pip3 install torch
As an update, now the Pytorch official site has the right version depending on your system:
https://pytorch.org/
I recommend using the official website for installation. Some of the previous awnsers may lead to a version that is not adequate.
After Activating conda environment
Use below command
python3 -m pip install torch torchvision
Example
(torchenv) ubuntu#user :~$ python3 -m pip install torch torchvision
Visit https://anaconda.org/pytorch/torchvision and you will find the solution
conda install -c pytorch torchvision
Try running:
conda install -c pytorch pytorch