I'm moving from a computer with windows xp to one with windows 7 (64 bit) and I want to install Python on the new machine. I'm currently using python 2.7 and 3.2 and a bunch of packages
1) Should I install the 64 bit versions?
2) How can I tell which packages I currently have, so that I can get those for the new machine?
If these are duplicates (my search skills seem to be failing), please point me to the threads where they're discussed.
You can use pip now for this purpose.
using pip list will give you a list of the packages that you have installed and the versions.
You could also use pip freeze and then copy the output of this to a file and then use this as a requirements files so you can install those exact modules and versions again on the new computer.
More information on pip is here is here
but to install from a requirements files you would use
pip install -r requirements.txt
Type help('modules') on the Python shell to get a list of all installed modules. If you can find stable 64-bit versions, then by all means select 64-bit builds for installations.
From your Python home folder go to ../Lib/site-packages/ and save the folder listing to a file, e.g. ls > ~/my-python-modules.txt on Linux/OSX, or dir > my-python-modules.txt on Windows. The file will contain all the additional modules that have been installed on your system. Also, from the same folder search for *.pth files: they might contain the names of modules that were installed as Python Eggs.
On Linux/OSX the location of the site-packages folder might vary: use locate -b site-packages to quickly find out where they are.
To reinstall the modules it is best to use your system's built-in package manager if it has one (this will be the case if you use Linux or MacPorts), otherwise you will need to use easy_install (the package is called setuptools) or pip (url). On Windows with modules that need C/C++ compilation it is easiest to use binary executable installers, unless you have a sane build environment like MS Visual Studio or MinGW. If you install binary packages then it is probably best to get the 64-bit version to match your architecture. Not sure if 32 bit versions will work or will event install.
Related
How do I install and run Python 3.8.1 on Linux? Python.org does not offer a Linux binary for Python 3.8.1.
I want to type:
dnf -y install python or dnf -y install python38
and have it install Python 3.8.1 on my RHEL 8.0 or 8.1 inside my minimal container that I want to keep small.
How would I make this happen?
I don't even see a download for Python for Linux on python.org.
Do people use Python on Linux?
There are no Linux binaries to be downloaded from Python.org
I have searched all over (internet search), and cannot find a way to install Python 3.8.1 easily on a minimal container.
I do not want to download the source and compile, because it is a small container that I am trying to keep small without a lot of overhead.
Reference:
https://www.python.org/downloads/release/python-381/
Two notes: I'm not sure how your container is set. You've tagged this as both RHEL and Fedora. These are two separate distributions. I can comment on Fedora.
Firstly, yes, Python is heavily used in the GNU/Linux world. Most distros use it as one of the languages to build the system and its packages. Linux servers are the only officially recommended servers for Python, or so I've read (will edit with source later if I can find it). Python.org does have Linux downloads, but in source files, packaged in compressed tarballs. This can promote searching the distro package manager first for distro compatibility (since being in a distro's repo should mean the version was vetted); these packages are precompiled unless otherwise specified. It also means the files are distro agnostic -- no need for .DEB, .RPM...
Fedora: There isn't a Fedora version listed in the post, but at least Fedora 31 has a development version, as they call it, of Python 3.8.1 in RPM format. (Fedora 32 is slated to have Python 3.8 at the system level.) You can get it with:
sudo dnf install python38
Be sure not to overwrite the system variables for python or python3; this mistake can cause systemic issues of varying magnitude. Once installed, you can create a virtual environment in whichever directory you'd like with:
python3.8 -m venv <venv_name>
To activate the venv, use:
. <path/to/venv>/<venv_name>/bin/activate
You can set an alias or symlink for ease. When the venv is activated, Python 3.8.x will be the Python version used when the interpreter is called. You should see your venv_name in parentheses, to the left of your PS1. To deactivate, use:
deactivate
The venv_name should be removed from the PS1, returning it to normal. Checking the Python version should return the system-level Python version.
If you check your Python version before and after the activation, it should be different.
python3 -V
This package may or may not have been sent downstream to RHEL. If you have the package available but want the full Python stack, or if it isn't available in RHEL's baseline repos, you may need to grab the source files and unpack the tarballs.
Alternatives are checking other repos, seeing about RPMs that someone else compiled from source, or checking out flatpak (which I haven't done).
Last note: compiling from source shouldn't result in a larger Python binary. You can delete any unnecessary extras, like the original archive file used for compiling, after you've extracted what you need. The action itself will only be stored in volatile memory, not on your disk.
By necessity I have a number of python 3.4 distributions on my system some of which are installed in non-user writable locations and some I have built myself using different compilers and 3rd party libraries (such as MKL).
I need to be able to reliably isolate each of these for use but can't use virtualenv / pyenv ... etc. As long as windows knows which executable to use the isolation is reasonably good. I then use "pip -t" to install to a directory which I can add to PYTHONPATH. The problem is that if packages installed by any distribution using the --user argument to pip placed in a single shared location, and cause me problems.
I was wondering if there is an easy way to tell python not to look in the AppData\Roaming\Python... directory when searching for packages.
When you try to install a package using pip (or even uninstall one), try to run your comand prompt opr powershell as administrator
I am working on an EC2 VM running Linux (I'm fairly new to Linux and Bash) which comes installed with Python 2.6. I upgraded to Python 2.7. When I try to install new modules, they install in /usr/lib/python2.6/site-packages but I need to change this to install in /usr/lib/python2.7/site-packages. I've tried a bunch of different ways to update the PYTHONPATH which I've found in various other post on Stackoverflow and other sites, but to no avail. Some I've tried are:
PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/site-packages export PYTHONPATH
PYTHONPATH="/usr/lib/python2.7/site-packages:$PYTHONPATH"
How can I update the install path to the new 2.7 path?
You covered how Python 2.7 was installed (which is a manual installation), how are you installing your modules?
If you sudo yum install <python-package>, you are going about this using system level (distribution specific) way of getting packages installed, which means it will only put packages in the system python location, in your case in the site-package directory in python2.6.
If you had used sudo pip install <python-package>, it should possibly work since you completely destroyed the default python installation which yum might have need (refer to Upgrade python without breaking yum).
With virtualenv, you can specify isolated, local locations for which you can install python packages to, isolating them from system level and you can fix a virtualenv to any available versions of python on your system, guaranteeing the right sets of libraries with the right sets of packages with all the correct versions (for python and the packages) specific to the needs of a particular application, which means you don't have to deal with the system/distribution level python path issues as that can be a huge source of headache. For example, on the system level you have a package by your distro that depends on some old versions of sqlalchemy, but in your actual application you need the most recent version, with virtualenv you can mask out the system level package and have the latest version installed locally there.
I decided today I better download python 3.4. So I go to the python/downloads page and do that. Now I am trying to make a new virtualenv using my new python module, mkvirtualenv -p python3.4 sandbox, but I get an error that it can't find my python executable.
The executable /Users/croberts/python3.4 (from --python=/Users/croberts/python3.4) does not exist
This is understandable, but I can't figure out where it is. The old versions of python are in /usr/bin/ but the new one didn't get installed there. How do you search for where a program is using the terminal?
According to the ReadMe.txt bundled with the installer, Python installs default to /Library/frameworks/Python.framework. I just did a test install and it ended up here specifically:
/Library/frameworks/Python.framework/versions/3.4/Python
Unless you changed the settings on the installer, that's where it should live. (If you installed it from source, I'd assume you'd know where you put it.) Something to note is that if you use Homebrew (and possibly other OSX package managers like MacPorts, though I haven't used it), installing Python through the PPC installer will cause a warning:
Warning: Python is installed at /Library/Frameworks/Python.framework
Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.
So if you do use Homebrew (and it's great), it's best to simply use brew install python3, which will put it into /usr/local/bin. Then you can alias python (or python3) to that version, instead.
I've downloaded python libraries (tar.gz) from external links. How to use these libraries, I mean in which directory under the python should I unzip such libraries.
How to use downloaded libraries with python when we are using:
windows 7
Ubuntu
Also how to install these libraries without using pip in Linux? Do we have to set path in windows7 to use the libraries?
Guys better to post comments then to give negative points. With your suggestion I can modify my post. I dont think you to be smart guy by rating negative points in any comments.
For Linux based systems (e.g., Ubuntu):
$ tar xzf package.tar.gz
$ cd package
$ python setup.py install
Also, look input pip https://pypi.python.org/pypi/pip
On Windows and Linux, all you need to do is unzip the archive somewhere, cd into and run the following command as administrator (usually by running cmd.exe as Administrator on Windows or by using sudo on Linux):
python setup.py install
If the package does not have a setup.py, it can get tricky. Most of the time the package just needs to be copied into your Python's site-packages folder.
You will find some packages that need to be built. On Linux, you can usually do this pretty easily. On Windows, you will need the appropriate compiler, usually a free version of Visual Studio will do, although you have to make sure you get the correct version of Visual Studio. I've heard reports that you can also use MingW.