Installing python 3 into venv? - linux

I wish to develop and deploy python 3 codes, along with python 3 modules to OSX Yosemite and CentOS 7, both come with python 2 preinstalled.
I had installed python modules via pip and got the idea around developing with python 3 on Fedora 21, but I am not sure what's the best way to do this with OSX and CentOS.
I am aware that we can install python modules into a venv environment to keep it isolated from the system. Is it possible to have the whole python 3 environment isolated in venv and deploy that on CentOS/OSX? I have experimented this approach with Docker, but am feeling this is too much of a sledgehammer approach.
Is there a standard python way to develop python 3 code on primarily python 2 OS like OSX and CentOS without populating what's already on the system?

sunnz,
$ virtualenv venv_name --python=python3
Btw, if you install python3 directly in your system (OSX or CentOS) nothing bad will happen.

Related

Installing Python 2.7 projects in a system with Python 3.10

I've come to a delicate situation:
My company's projects are all based in Python 2.7 and use specific PATH and PYTHONPATH exports to get around each other. The new machine I received has Ubuntu 22.04 and Python 3.10 preinstalled. My previous used to have Python 2.7 and I just installed 3.x on top and it worked just fine, at the beginning. I ended up messing up all the version altogether and everything seemed broken. So now I'm cautious on how to proceed
I've watched numerous tutorials online about setting up a virtual environment and how 'easy' it is to work with multiple version but seems that don't do the trick.
I would like to set up a virtual environment in Python 2.7 where I can just
python setup.py install ....
with all my packages and install them using python 2.7
At the same time, I'd like Python 3 to be available (because I'm futurizing some of these projects) to also install them using Python 3:
python3 setup.py install ...
What is the best strategy to implement this on my machine? Python 2 looks like it's not installed at all. Should I just install it on top of 3.10 ?

Installing biopython for python2

I have python 2 and 3 installed and need to run a script written for python 2. Said script needs biopython. So, how do I install biopython such that it's available specifically for python 2? (Linux environment btw). Thanks!

Run scrapyd in Python 3.6

I've been looking around and I can't seem to find an answer on how to run scrapyd in Python 3 and above. When I run it it keeps defaulting to python 2.7, though I recall reading in the docs or elsewhere that scrapyd supports python3:
https://scrapyd.readthedocs.io/en/stable/news.html#id1
Running on an AWS Ubuntu 18.04 server. What am I doing wrong? How can I change to Python 3.4 and above?
I'm having problems because I'm using abstract inheritance in my spiders which python 2.7 doesn't support.
Edit: I'm able to run Scrapyd in Python 3 using a virtual environment, but how would you do it without one?
Simplest solution is use a virtual enviroment.
Since you are using Ubuntu and you can make it work using a venv I assume you installed scrapy using pip instead of pip3. Since Py2.7 is the stardard reference to python in Ubuntu, when running pip it will execute pip for py2 instead of py3.
Another way would be uninstalling pip uninstall scrapy and installing it again using pip3 pip3 install scrapy. This should fix the reference to scrapy. If by any chance you also use scrapy in py2.7 and therefore can't uninstall, then you have another reason to use venv.

How to install python3.6 in parallel with python 2.7 in Ubuntu 18

Setting up to start python for data analytics and want to install python 3.6 in Ubuntu 18.0 . Shall i run both version in parallel or overwrite 2.7 and how ? I am getting ambiguous methods when searched up.
Try pyenv and/or pipenv . Both are excellent tools to maintain local python installations.

Using Python 3.6 when OS uses 3.7

I have a new laptop (dell xps 9570) on which I have installed fedora 29 which I will use for coding/data science.
Fedora 29 uses Python 3.7 but Tensorflow is not compatible with that version, so how can I use Python 3.6 without overriding system's default?
I have heard recently about virtual environment for Python but I don't know much about it, so I wonder is it possible to install Python 3.6 on a virtual environment?
Thank you
You can't install Python itself with pip; just Python packages.
You could use something like Conda. That provides a more separate (virtual) environment, including the Python executable. Conda also provides TensorFlow (up to version 1.12.0), which should make for a relatively easy installation:
conda create -n tensorflowenv python=3.6 tensorflow
Conda may take a while to solve the environment; just let it run, and it will likely install Python 3.6 in the Conda environment (whilst keeping your system Python 3.7), where you can then use TensorFlow.

Resources