Can Anaconda and a more recent version of Python coexist in Windows 10? - python-3.x

I am taking a beginner course in Python so I downloaded and installed Anaconda on a
Windows 10 OS. It is possible to install the last version of Python, say 3.9.x or 3.10 to be run on VSCode. How do I manage to avoid conflicts between them. Can anyone tell how should I do because I have to use that text editor. Thanks in advance.

Yes, but Anaconda includes an environment management tool, Conda, and so it would be more idiomatic to use that to create a new environment, rather than installing a native, system- or user-level Python interpreter. If you are using Anaconda, then from Anaconda Command Prompt try
conda create -n py39 python=3.9
or
conda create -n py310 python=3.10
Note the argument used in the -n (or --name) is arbitrary - feel free to name environments as you'd like.

Related

Manage two different versions of Python

In my system Python 3.8 version already install, but I want create virtual env for version 3.7 on vscode so how can I do>
To work on different environments, you can use Anaconda Prompt.
You can follow the steps given in this: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

Visual Studio Code with Python for Windows AND Anaconda

I'm trying to use Visual Studio Code with both Anaconda and Python for Windows.
I have both installed, and I have the visual studio code extensions for both.
But no matter what I do now the Conda Base gets activated -
(base) PS C:\Users
even though the Python for Windows is the selected version
or if I try to activate an environment I get a mix of both, the venv with python for windows and the conda base activated.
(venv_iocparser) (base) PS C:\Users\
The settings.json file in this folder only has python for windows in the 'python.pythonPath'; with no mention of conda, but still activates the conda base.
Does anyone know a good article that walks through setting VSCode up with both? With python for windows as the default?
Thank you!
Had a similar issue. Its most likely since you installed VS Code with Anaconda, for some reason or another it just assumes thats what env you want when starting it.
To get out of it just run $ conda deactivate and then activate whatever env you want after that. I fixed it by changing the PATH for the python to only point at the non-conda versions though. I also had uninstalled it all and reinstalled it all at one point though.

how to verify whether latest python version installed properly

when I try to check python version in Centos7 by typing command
1) python --version
-bash: /usr/local/bin/python3.6: No such file or directory
OR
2) which python
"alias python='/usr/local/bin/python3.6'.
Could anyone explain me why it shows like this instead of showing python version?
Thanks.
In order to sum up, for future people who will look in this question:
when installing different versions of python on linux using package manager (in this case yum because you are using CentOS, but it might be apt or something else) linux installs the side-by-side, meaning you have all of the versions installed together.
If you want to use a specific version other than your linux distribution diffault one you need to call it explicitly (i.e. python3.6 or python3.8)
Make sure you are looking for the wanted python version on the right path.
When you want to run some version of python after installing it I suggest you to just write python in the bash and just hit tab+tab and the bash will suggest all the installed versions in the $PATH.

Downloading and installing PyBluez for a 64-bit Windows 10 PC?

I'm trying to use bluetooth with python, and I came across a module - pybluez. Right then, I tried installing it by running pip install pybluez. The package was located and downloaded, but it raised an error when running python setup.py egg_info.
I then tried to download pyBluez from this link https://pypi.python.org/pypi/PyBluez
But, it said that the Python version installed on my PC is not 2.7 ( I have 2.7.10; do I need 2.7.0 for this?) Also, this download link is for a 32-bit system, and that might be the reason it does not run on mine.
So I ask:
1. How do I fix this error?
Error in the output when I try to install pybluez using pip:
2.Does download using https://pypi.python.org/pypi/PyBluez need python 2.7.0, and a 32-bit system? If so, can someone suggest a better way for a 64-bit system?
3.Any other bluetooth module that could work as a substitute?
I have successfully built pybluez for win10x64 with python3.6
Download and install windows 10 build tools: https://www.visualstudio.com/pl/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15
Run 'Developer Command Prompt for VS' as administrator
Clone pybluez repo https://github.com/karulis/pybluez
cd to directory with repo
run python setup.py install
Happy bluetoothing
This is an "expanded solution" which supplements the other answers posted.
Bluetooth is readily supported on Linux in basically any context. Python 3 built-in socket objects work over bluetooth even. But for Windows, there are hoops to jump through. The standard solution for this is to use PyBluez. If you're really lucky, you might be able to install with just pip install PyBluez-win10. If that fails, however, the way to go is an installation via a pre-compiled "wheel".
A given wheel only works for your specific context, however, i.e. exact Python version. So, for the sake of future proofing, if you are going to need PyBluez, you should know how create a wheel from the source for yourself. It's a long, annoying process if you don't have the all the software required already and are not familiar with some parts of the process e.g. using Anaconda. So, if you are working in a team, I suggest having one person burn their time on this and then share the wheel with everyone (who are hopefully on the same version of Python!).
The following is a paraphrased version of what is posted here: https://github.com/pybluez/pybluez/issues/180 which includes the actual developer's comments and methodology.
Download and run the "Visual Studio Build Tools" installer:
For an official list of exact compilers and links to match against target Python versions, refer to: https://wiki.python.org/moin/WindowsCompilers
Here's the 2019 Build Tools link, which works with Py3.7:
https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
During the install you MUST select BOTH "Visual C++ build tools" AND "Universal Windows Platform build tools". Leave the default options alone within those (e.g. including the Windows 10 SDK).
Note: this requires 15GB of disk space, and some patience!
Install "Miniconda":
https://docs.conda.io/en/latest/miniconda.html
Select the one which matches the bit set (32 vs 64) of the destination Python version
you wish to install PyBluez into.
Clone the PyBluez source repo to a temp location (e.g. your desktop). Then, launch the terminal and change into that directory:
git clone https://github.com/pybluez/pybluez
cd pybluez
If you did NOT put conda on the system path (as the installer recommends NOT doing so), you can add it for this local CMD session per this example command:
set CONDA_DIR=%USERPROFILE%\Miniconda3
set PATH=%CONDA_DIR%\condabin;%PATH%
Create a dedicated environment to build pybluez with the desired Python version. Then, launch that. The example below uses Python 3.7 but the same steps will also work for other versions (including Py 2.x etc)
conda create -y -n pybluez python==3.7
activate pybluez
Build a wheel file. Then, leave the dedicated environment.
python setup.py install
python setup.py bdist_wheel
deactivate
Copy the wheel to your desktop. From there, you can do with it as you wish. Then, delete the pybluez conda environment and the source repo, (as you no longer need either of them).
copy .\dist\*.whl "%USERPROFILE%\Desktop"
cd..
rd /s /q "%CONDA_DIR%\envs\pybluez"
rd /s /q pybluez
Finally, you can install the wheel to a target Python instance and/or store/share it:
The name of these files and the path will vary, so define those first for your use case
set PYBLUEZ_WHEEL=%USERPROFILE%\Desktop\PyBluez-0.22-cp37-cp37m-win_amd64.whl
set PYTHON_PATH=python
Install the wheel:
%PYTHON_PATH% -m pip install "%PYBLUEZ_WHEEL%"
Confirm installation:
%PYTHON_PATH% -c "import bluetooth; print(bluetooth.__version__)"
I downloaded a Python 3.6 wheel from here (wheels for python 2.7, 3.5, 3.6, 3.7 available too).
I installed it in my virtual environment via
pip install PyBluez-0.22-cp36-cp36m-win_amd64.whl
One command solution.
pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez

PyCharm + conda + pip packages not recognized

I can say I am quite new to the world of Python but not to programming. I have been using PyCharm over the last year and I got Python conda distribution to make my life easier with package management.
Lately, I have been trying to play with a package known PuLP which was not available to download via conda but I installed using pip. I realized that although PyCharm recognizes pulp when running my code, it is not in the available packages and I am not sure that the same version of PuLP is used in and out of PyCharm. Specifically, when I run the pulpTestAll command that looks for installed solvers from my terminal, the recognized solvers are different than those recognized when I run exactly the same script within PyCharm.
Can someone give me a tip on how to fix this?
How do I import modules in pycharm?
You may look here. Maybe you have to specify an interpreter for the Conda environment. To do that when you are choosing an interpreter at the right there is a gear at the right. After you press it, you may add a new interpreter and you can choose Conda Environment.

Resources