I am completly new to Conda and I have been struggling for a day without success.
I would like to use the pvtrace module. The documentation specifically says to run the following commands to install the package:
conda create --name pvtrace-env python=3.7.8
conda activate pvtrace-env
conda install Rtree
pip install pvtrace
I have the following error:
PackagesNotFoundError: The following packages are not available from current channels:
- python=3.7.8
I have Anaconda 3 which original Python version is 3.9. I installed the version 3.7, but it did not solve my problem.
Not sure why, but the defaults (main/anaconda) channels are missing specifically the Python 3.7.8 build. This is available through Conda Forge, so, instead try
## one should prefer to list all known package at creation
conda create -n pvtrace-env -c conda-forge python=3.7.8 pip rtree
conda activate pvtrace-env
pip install pvtrace
Alternatively, use a YAML file:
pvtrace-env.yaml
name: pvtrace-env
channels:
- conda-forge
dependencies:
- python=3.7.8
- rtree
- pip
- pip:
- pvtrace
which is used as:
conda env create -n pvtrace-env -f pvtrace-env.yaml
Related
When trying to compile a file, using the command conda -m nuitka -onefilestrict test.py
I get an error CommandNotFoundError: No command 'conda nuitka'.
Used conda config --add channels conda-forgeand conda config --set channel_priority strict before installation (conda install nuitka)
When I enter conda search nuitka - I get a lot of packages starting from the 0.5.x to 0.7.7 version.
But when I use - conda list nuitka. I get nothing
conda --version
conda 4.10.3
You seem to have never actually isntalled the package
conda search
lists all packages that you could install that match the given name
conda list
lists the currently installed packages. So you need to do
conda install nuitka
When I install the latest version of anaconda distribution, it comes with flask version 1.1.2. However, I need to install flask version 2.0. How can I install flask version 2.0 (in the base environment) while keeping other existing packages installed such as sklearn and numpy, etc.?
First do conda activate base,
Then you can either do pip install flask==2.0.0 or conda install -c conda-forge flask==2.0.0. Both are okay as long as you do conda activate base first.
You should consider creating a new environment for your project and not mess with the base environment.
First do conda create -n newname, then conda activate newname.
Then you can do conda install -c conda-forge numpy pandas sklearn flask==2.0.0, you can also do pip install numpy pandas sklearn flask==2.0.0. You can install everything you need in one line.
In a nutshell:
conda activate base
conda remove flask
conda install -c conda-forge flask
Line 1: to activate your base virtual environment
Line 2: in order to avoid any conflict, remove flask 1.1.2
line 3: install the latest flask version via the channel conda-forge (2.0.1 as for now)
If you want the 2.0.0 you should do this: conda install -c conda-forge flask=2.0.0
Explanations:
Channels:
conda uses channels (like repositories where the packages are stored). By default, the channel is the anaconda channel. So, if you installed flask with conda install flask that is the same as if you did conda install -c anaconda flask. And from this page (https://anaconda.org/anaconda/flask) you can see that the actual version on this channel is 1.1.2.
About the update part:
In general, to update all your packages in a virtual environment, you first have to activate your virtual environment with conda activate [virtual_environment_name] and then conda update --all.
But as you can see from the previous link, on the default channel (anconda), the latest version is 1.1.2, so, strictly speaking, you can't update flask to a version greater than 1.1.2.
But, because on the conda-forge channel the latest version is -as for now- 2.0.1, if you install flask from this channel, you will get flask 2.0.1.
Using pip in a Conda environment:
An other option mentionned by #anarchy too is to use pip install flask=2.0.0 but you should avoid that. See: https://www.anaconda.com/blog/using-pip-in-a-conda-environment and
Is that a bad idea to use conda and pip install on the same environment?.
About not using the base environment directly:
And in order to have a clean workspace, it's a good practice to create a virtual environment other than the base environment for your projects. You can create and then activate a new environment named for example "myenv" like this:
conda create -n myenv
conda activate myenv
And so the complete code would be:
conda create -n myenv
conda activate myenv
conda install -c conda-forge flask
And finally if you want to install the latest versions of other packages like numpy and sklearn, you should use conda-forge too:
conda install -c conda-forge scikit-learn
conda install -c conda-forge numpy
I have been using the following conda & python verison:
conda version : 4.6.14
conda-build version : 3.17.8
python version : 3.7.3.final.0
I installed simpletransformers in the following manner:
conda create -n simpletransformers python pandas tqdm
conda activate simpletransformers
conda install pytorch cpuonly -c pytorch
conda install -c anaconda scipy
conda install -c anaconda scikit-learn
pip install transformers
pip install seqeval
pip install tensorboardx
pip install simpletransformers
After doing so, I've been trying to import the classification model without much luck:
import simpletransformers
I get the following error:
ModuleNotFoundError: No module named 'simpletransformers'
Can someone point out where I'm going wrong? I'm using PyCharm as my IDE.
The setup docs work for me on Mac and Ubuntu using Anaconda:
Install Anaconda or Miniconda
Create a new virtual python 3.7 environment and install pandas and tqdm
conda create -n simplet python=3.7 pandas tqdm
conda activate simplet
PyTorch
3 a. GPU (use_cuda=True in your model): conda install pytorch cudatoolkit=10.1 -c pytorch
3 b. CPU (use_cuda=False in your model): conda install pytorch cpuonly -c pytorch
If you want to use fp16 training on an NVIDIA GPU install apex (don't use pip)
Install simpletransformers.
pip install simpletransformers
Download the .whl file from "https://pypi.org/project/simpletransformers/#files"
Open command prompt
type pip install "path/simpletransformers-0.13.2-py3-none-any.whl" and hit enter
Check whether the package gets installed.
Note that simpletransformers requires Python '>=3.6'
Whenever I have a package that is not available via Anaconda Cloud, i.e., I have to install from PyPI or GitHub, then I create a YAML environment definition for it. This follows the best practices enumerated in "Using Pip in a Conda Environment".
The advantage of a YAML is that it allows Conda to solve for everything at once and it lets one treat envs as immutable objects (i.e., if you need to alter the env, edit the YAML and recreate). This helps avoid the mess that inevitably seems to result from running a series of conda install, pip install, or conda update commands.
For me this is a multi-stage process, but it has been a reliable workflow for me:
Workflow for Mixed Conda-PyPI Environments
Look at the setup.py or requirements.txt of the non-Conda package. Here it is for simpletransformers.
For each requirement, check Anaconda Cloud (or conda search) to see if it is available as a Conda package.
If it is available, add it to the YAML file as a (non-pip) dependency. This ensures that everything that can come from Conda does.
Also, keep track of the channels that these packages come from. Note, I will not use a private channel I am unfamiliar with. In this case pytorch, conda-forge, and defaults (i.e., anaconda) suffice.
Include the packages that are PyPI-only under the pip section of the YAML, including the main package of interest (i.e., simpletransformers). Technically, you don't need to include the other dependencies, since pip will pull them in automatically, but I like to keep them explicit so that if I ever update the YAML I might check again if someone ported the PyPI packages to Conda Forge.
Create the env using the YAML
conda env create -n st_env -f simpletransformers.yaml
Check to see if any additional packages were implicitly pulled in as dependencies from PyPI, but were actually available through Conda. Edit the YAML to put these in the Conda dependencies section. In this case, keras is apparently also needed.
Remove the env and recreate using the updated maximally Conda version.
Most important: never change the env except through editing the YAML.
YAML for SimpleTransformers Environment
simpletransformers.yaml
name: st_env
channels:
- pytorch
- conda-forge
- defaults
dependencies:
- python=3.7
- pandas
- tqdm
- cpuonly
- pytorch
- transformers
- scipy
- scikit-learn
- requests
- tensorboardx
- keras
- pip
- pip:
- seqeval
- simpletransformers
Install with
conda env create -n st_env -f simpletransformers.yaml
If you have pip installed in your environment, just do hit a pip install simpletransformers in your terminal or If you're using jupyter notebook/colab, etc. then paste !pip install simpletransformers in your first cell and run it.
Then import simpletransformers
import simpletransformers
After I run the conda env create -f environment.yml in Conda, I receive the following warning:
Warning : you have pip-installed dependencies in your environment file, but you do not list pip itself as one of your conda dependencies...
What does this mean and what should I be doing instead?
When creating an environment the warning disappeared by including - pip explicitly in the yaml file. Yes, it is a bit awkward because if your environment has pip packages you already have declared that you used pip packages with - pip:
The yaml file would look like:
# Packages omitted for simplicity
name: myenv
channels:
- anaconda
- conda-forge
- defaults
dependencies:
- python
- scipy
- pip
- pip:
- datetime
At the time of creating a new environment from scratch this warming can be avoided by explicitly installing pip, for instance with: conda create -n env_with_pip python=3.7 numpy pip
In your environment yml file under list of the packages you install through conda you must also add pip as a package to be installed. This installs the pip, and so your pip packages can be installed using this pip.
Previously pip was shipped with conda but now we have to explicitly install pip when using conda
i want to install hazm on anaconda3 .I use this command to install this package with downloaded package :
conda install hazm-0.4.tar.gz
or this command in pycharm :
conda install hazm
in both manner it gives me this error:
Solving environment: failed
PackagesNotFoundError: The following packages are not available from
current channels:
hazm
Current channels:
https://repo.continuum.io/pkgs/main/linux-64
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/linux-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/linux-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/linux-64
https://repo.continuum.io/pkgs/pro/noarch
what is the problem ?
The instruction on the hazm documentation page is to install the package using pip:
pip install hazm
pip can be used to install non-conda packages in a conda environment, if there isn't a conda package available.
Reading this question and its answers it sounds as if the latest version of hazm may not install under Windows because of a dependency issue. If you're on Windows you need to specify the 0.4 version, either with hazm==0.4 or simply by pointing to the archive you downloaded. I was able to install hazm 0.4 from the gz archive on Anaconda under Windows without errors as follows:
conda create -n testhazm python=3.4 nltk=3.0.0
activate testhazm
pip install hazm-0.4.tar.gz
(If I allowed conda to use the latest version of nltk, the installation went OK but I got an error when I actually started Python and tried to import hazm. You may be able to get it working with a more recent version of nltk and/or Python by experimenting.)
Background:
When you do conda install hazm the error message The following packages are not available from current channels: hazm means exactly what it says: the channels specified in your current conda configuration do not contain this package.
Often, packages that are not available on the default conda channels can be found on conda-forge, but I checked this with conda search hazm -c conda-forge and it looks like it's not there either.
To use the command conda install hazm-0.4.tar.gz, the downloaded file would need to be a conda package, not just a Python module.