I'm new to Python and just downloaded Anaconda Python. Anaconda comes with Sympy 1.4 but I need to use Sympy 0.7.3.
I see that Anaconda Navigator has the option to replace 1.4 with other versions (specifically 1.1.1 or 1.2 or 1.3) however 0.7.3 is not in the list. I have found an archive with version 0.7.3 at https://anaconda.org/anaconda/sympy/files?version=0.7.3 and I tried adding that path to the channel list but it was flagged as an invalid channel. How do I import Sympy 0.7.3?
I'm running on Windows and am doing all this because I want to run Symoro.
Any help is very much appreciated!
Anaconda recently dropped support for what was called their free channel and this has resulted in many older packages becoming inaccessible by default. Unfortunately, that older version of SymPy is in that part of the repository. You have two options:
Download the tarball and install from that.
Enable access to the free channel.
SymPy 0.7.3 is only available for Python 2.6, 2.7, or 3.3. If you want to use Python 2.7 then downloading should be the easiest route; for Python 3.3 (or 2.6 for some reason), I'd recommend the latter option, because almost all the other packages for these versions are also in the free channel.
In either case, you will use Anaconda Prompt (or another shell) and need to create a new environment, because it is generally a bad idea to force major changes into the Anaconda base environment.
Option 1: Installing from the Tarball
First, you need create the new Python 2.7 env. Let's call it my_env:
conda create --name my_env python=2.7
If there is other software you know you'll want, then you can also include that after the python=2.7.
Download the file sympy-0.7.3-py27_0.tar.bz2 (this is the win-64 version - others are where you pointed out already).
Install it:
conda install -n my_env sympy-0.7.3-py27_0.tar.bz2
Test your new env:
conda activate my_env
python -c "import sympy; sympy.doctest('polynomial')"
Option 2: (Temporarily) Enabling the free Channel
Just note that I wouldn't generally recommend keeping this enabled since it really tends to slow down the Conda solver (see "Why we removed the free channel in Conda 4.7). I'll recommend disabling it again (step 3), but keep in mind that if you ever need to make adjustments to your SymPy 0.7.3 env, you'll probably need to re-enable it.
Enable the free channel:
conda config --set restore_free_channel True
Create your new env:
conda create --name my_env python=3.3 sympy=0.7.3
Disable free channel
conda config --set restore_free_channel False
Test your SymPy env
conda activate my_env
python -c "import sympy; sympy.doctest('polynomial')"
Have a look at installing packages on anaconda
To install a specific version of a package such as SciPy:
conda install scipy=0.15.0
So try
conda install sympy=0.7.3
Seems to do the trick for me. It's in the default conda channel so you shouldn't need to change or add a channel
Related
I recently created a new Anaconda (Windows) environment in order to move from tensorflow 1.2 to tensorflow 2.0. My base environment is 1.2, and I created tensorflow-20 in order to install the new version. I did the install from the anaconda command line within the (tensorflow-20) environment. But now everything is messed up.
Now, in Anaconda Navigator, it still shows Tensorflow 1.2.1 as the installed version for base. But in the (base) environment from the Anaconda command line, it shows the version as 2.0.0. Furthermore, in Anaconda Navigator, tensorflow-20 shows no installed packages, including python even.
I feel like I'm fundamentally misunderstanding something here. Can anyone provide some guidance?
How did you install tensorflow 2.0 in the new conda env?
IF with pip, run 'where pip' see if you are using the pip installed
in the base env. You can run 'conda create -n tensorflow-20 pip' to get a pip installed in the new env. Then activate tensorflow-20 and install tensorflow 2.0 with pip.
IF with conda, run 'where conda' to check the same thing.
Preface:
If you install Anaconda on your local machine, it makes sense to install it as Admin. However, if this is not possible, e.g. on an enterprise-managed computer, you must carefully check to use only folders where your user has write permission.
Contribution:
After having experienced a cracked-up package management, I read deeper into that topic. Best Practise: Always try to install everything via conda / Anaconda and best possibly from their central repositories.
If you have a special package, which is e.g. built by local software developers and not published, you can install it from the .tar archive. At that point, I am referring to following documentation: https://docs.anaconda.com/anaconda/user-guide/tasks/install-packages/
My Ubuntu system is on python 2.7.15
conda install -c anaconda flask
Anaconda always installs python 3.5 with Flask and other packages. How can I not install python 3.7 and leave python 2.7.15 as is when installing anaconda packages?
The Python you install with anaconda does not interfere at all with your system Python. You can use Anaconda to have multiple Pythons (in multiple conda environments) besides the system Python. You just have to make sure which one is invoked when you run scripts and make sure it's the one you intended.
To answer the "literal" question you asked, you can specify the Python version when installing something:
conda install -c anaconda flask python=2
This will keep your Python at version 2 or report a mismatch if the package you want to install isn't available on anaconda for Python 2. The number of packages dropping Python 2 support is increasing because Python 2 is near it's "end of life", so don't expect to get latest or even near-latest releases of the packages when keeping at Python 2.
Personally I would recommend to create a different environment instead of trying to install to much into the base environment:
conda create -n mypython2environment python=2 flask
And by activating that environment you should be able to use the packages you installed in that environment:
activate mypython2environment
Several IDEs have built-in support for conda environments, so these may be helpful (especially in making sure you use the correct environment and thus the correct Python).
It makes me crazy, In anaconda I create the environment with the defualt iterpreter python3.4 Next I install pytorch 0.4.1
conda install pytorch=0.4.1 cuda80 -c pytorch
After this I found that the pytorch was installed in python3.6!
And the environment defualt interpreter is chaged from python3.4 to python3.6.
I am very confused what happend ? How shoud I fix it back? change defualt python back to python3.4? Hope some one could help me.
The commands I typed in are as follows:
conda create -n pointgen python=3.4 ipykernel
source activate pointgen
conda install pytorch=0.4.1 cuda80 -c pytorch
Thats all. What Novak said is right, there is remaining question is how could I manually change the python version from 3.6 back to 3.4, is there any config file I can deal with?
As you can see here there is no version of pytorch for python3.4... The default version of pytorch is for python3.6 and that is the version you installed installed. In the process anaconda prompts you that it will have to upgrade/downgrade some package versions and there is probably the the line in which it says it will upgrade python to 3.6
I tried the conda search --outdated, there are lots of outdated packages, for example the scipy is 0.17.1 but the latest is 0.18.0. However, when I do the conda update --all. It will not update any packages.
update 1
conda update --all --alt-hint
Fetching package metadata .......
Solving package specifications: ..........
# All requested packages already installed.
# packages in environment at /home/user/opt/anaconda2:
#
update 2
I can update those packages separately. I can do conda update scipy. But why I cannot update all of them in one go?
TL;DR: dependency conflicts: Updating one requires (by it's requirements) to downgrade another
You are right:
conda update --all
is actually the way to go1. Conda always tries to upgrade the packages to the newest version in the series (say Python 2.x or 3.x).
Dependency conflicts
But it is possible that there are dependency conflicts (which prevent a further upgrade). Conda usually warns very explicitly if they occur.
e.g. X requires Y <5.0, so Y will never be >= 5.0
That's why you 'cannot' upgrade them all.
Resolving
Update 1: since a while, mamba has proven to be an extremely powerful drop-in replacement for conda in terms of dependency resolution and (IMH experience) finds solutions to problems where conda fails. A way to invoke it without installing mamba is via the --solver=libmamba flag (requires conda-libmamba-solver), as pointed out by matteo in the comments.
To add: maybe it could work but a newer version of X working with Y > 5.0 is not available in conda. It is possible to install with pip, since more packages are available in pip. But be aware that pip also installs packages if dependency conflicts exist and that it usually breaks your conda environment in the sense that you cannot reliably install with conda anymore. If you do that, do it as a last resort and after all packages have been installed with conda. It's rather a hack.
A safe way you can try is to add conda-forge as a channel when upgrading (add -c conda-forge as a flag) or any other channel you find that contains your package if you really need this new version. This way conda does also search in this places for available packages.
Considering your update: You can upgrade them each separately, but doing so will not only include an upgrade but also a downgrade of another package as well. Say, to add to the example above:
X > 2.0 requires Y < 5.0, X < 2.0 requires Y > 5.0
So upgrading Y > 5.0 implies downgrading X to < 2.0 and vice versa.
(this is a pedagogical example, of course, but it's the same in reality, usually just with more complicated dependencies and sub-dependencies)
So you still cannot upgrade them all by doing the upgrades separately; the dependencies are just not satisfiable so earlier or later, an upgrade will downgrade an already upgraded package again. Or break the compatibility of the packages (which you usually don't want!), which is only possible by explicitly invoking an ignore-dependencies and force-command. But that is only to hack your way around issues, definitely not the normal-user case!
1 If you actually want to update the packages of your installation, which you usually don't. The command run in the base environment will update the packages in this, but usually you should work with virtual environments (conda create -n myenv and then conda activate myenv). Executing conda update --all inside such an environment will update the packages inside this environment. However, since the base environment is also an environment, the answer applies to both cases in the same way.
To answer more precisely to the question:
conda (which is conda for miniconda as for Anaconda) updates all but ONLY within a specific version of a package -> major and minor. That's the paradigm.
In the documentation you will find "NOTE: Conda updates to the highest version in its series, so Python 2.7 updates to the highest available in the 2.x series and 3.6 updates to the highest available in the 3.x series."
doc
If Wang does not gives a reproducible example, one can only assist.
e.g. is it really the virtual environment he wants to update or could Wang get what he/she wants with
conda update -n ENVIRONMENT --all
*PLEASE read the docs before executing "update --all"!
This does not lead to an update of all packages by nature. Because conda tries to resolve the relationship of dependencies between all packages in your environment, this can lead to DOWNGRADED packages without warnings.
If you only want to update almost all, you can create a pin file
echo "conda ==4.0.0" >> ~/miniconda3/envs/py35/conda-meta/pinned
echo "numpy 1.7.*" >> ~/miniconda3/envs/py35/conda-meta/pinned
before running the update. conda issues not pinned
If later on you want to ignore the file in your env for an update, you can do:
conda update --all --no-pin
You should not do update --all. If you need it nevertheless you are saver to test this in a cloned environment.
First step should always be to backup your current specification:
conda list -n py35 --explicit
(but even so there is not always a link to the source available - like for jupyterlab extensions)
Next you can clone and update:
conda create -n py356 --clone py35
conda activate py356
conda config --set pip_interop_enabled True # for conda>=4.6
conda update --all
conda config
update:
Currently I would use mamba (or micromamba) as conda pkg-manager replacement
update:
Because the idea of conda is nice but it is not working out very well for complex environments I personally prefer the combination of nix-shell (or lorri) and poetry [as superior pip/conda .-)] (intro poetry2nix).
Alternatively you can use nix and mach-nix (where you only need you requirements file. It resolves and builds environments best.
On Linux / macOS you could use nix like
nix-env -iA nixpkgs.python37
to enter an environment that has e.g. in this case Python3.7 (for sure you can change the version)
or as a very good Python (advanced) environment you can use mach-nix (with nix) like
mach-nix env ./env -r requirements.txt
(which even supports conda [but currently in beta])
or via api like
nix-shell -p nixFlakes --run "nix run github:davhau/mach-nix#with.ipython.pandas.seaborn.bokeh.scikit-learn "
Finally if you really need to work with packages that are not compatible due to its dependencies, it is possible with technologies like NixOS/nix-pkgs.
Imagine the dependency graph of packages, when the number of packages grows large, the chance of encountering a conflict when upgrading/adding packages is much higher. To avoid this, simply create a new environment in Anaconda.
Be frugal, install only what you need. For me, I installed the following packages in my new environment:
pandas
scikit-learn
matplotlib
notebook
keras
And I have 84 packages in total.
I agree with Mayou36.
For example, I was doing the mistake to install new packages in the base environment using conda for some packages and pip for some other packages.
Why this is bad?
1.None of this is going to help with updating packages that have been > installed >from PyPI via pip, or any packages installed using python
setup.py install. conda list will give you some hints about the
pip-based Python packages you have in an environment, but it won't do
anything special to update them.
And I had all my projects in the same one environment! And I used update all -which is bad and did not update all-.
So, the best thing to do is to create a new environment for each project. Why?
2. A Conda environment is a directory that contains a specific collection of Conda packages that you have installed. For example, you
may be working on a research project that requires NumPy 1.18 and its
dependencies, while another environment associated with an finished
project has NumPy 1.12 (perhaps because version 1.12 was the most
current version of NumPy at the time the project finished). If you
change one environment, your other environments are not affected. You
can easily activate or deactivate environments, which is how you
switch between them.
So, to wrap it up:
Create a new environment for each project
Be aware for the differences in conda and pip
3.Only include the packages that you will actually need and update them properly only if necessary.
if working in MS windows, you can use Anaconda navigator. click on the environment, in the drop-down box, it's "installed" by default. You can select "updatable" and start from there
To update all possible packages I used conda update --update-all
It works!
I solved this problem with conda and pip.
Firstly, I run:
conda uninstall qt and conda uninstall matplotlib and conda uninstall PyQt5
After that, I opened the cmd and run this code that
pip uninstall qt , pip uninstall matplotlib , pip uninstall PyQt5
Lastly, You should install matplotlib in pip by this code that pip install matplotlib
On my Ubuntu 14.04, I have installed tensorflow, using "pip", as specified in the Tensorflow Installation instructions and I made sure it was working by importing it in python and it did work.
Then, I installed Anaconda and it changed my .bashrc file by adding the following line to it:
export PATH="/home/sonny/anaconda2/bin:$PATH"
But because of this change, now it looks into the PATH above, which doesn't contain tensorflow. now I can't import tensorflow in my python code.
What is the proper way to extend the $PATH environment variable so that it stays using everything from anaconda2 but it becomes able to import "tensorflow"?
I solved the problem but in a different way!
I found a link where the tensorflow.whl files were converted to conda packages, so I went ahead and installed it using the command:
conda install -c https://conda.anaconda.org/jjhelmus tensorflow
and it worked, since the $PATH points to anaconda packages, I can import it now!
Source is here
Since v0.10.0, tensorflow is a community maintained conda package in the conda-forge channel. Hence, it can be installed directly with the following command:
conda install -c conda-forge tensorflow
The instructions on the TensorFlow documentation has also been updated.
To facilitate future updates, it is probably a good idea to add conda-forge channel into your conda config:
conda config --add channels conda-forge
In fact, tensorflow=0.10.0rc0 was recently added onto the Anaconda default channel and will be installed instead if the conda-forge channel is not specified:
conda install tensorflow
I had the same problem and decided it was easiest to start over, install Anaconda first and then TensorFlow after that.
I suspect that pip is giving you a TensorFlow installation in cpython, not anaconda.
How about a virtualenv?
# Create env
$ virtualenv --python=/path/to/anaconda /path/to/your/env
# Activate env
$ source /path/to/your/env/bin/activate
# Install Tensorflow
$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
Install tensorflow from the following command. Conda will take care of the installation process.
conda install -c conda-forge tensorflow
I solved the problem using this:
conda create --name=tensorenv python=3.4
source activate tensorenv
Actually, the TensorFlow Official website made every detail of installing.
The Operation System Windows, Mac OS, Ubuntu; the environment with GPU or just CPU, every single detail of problems you may come up with.
Check this out
Installing TensorFlow on Ubuntu with Anaconda
you will not regret.
Once you visit that you may also find like
Installing TensorFlow on Windows with Anaconda