If not, please read some alternative installation methods, and extra details below. Hopefully the installation instructions above worked for you. If in doubt, use separate names for them (eg requirements-desktop.txt, requirements-glamdring.If it works, you are ready to go! If not there are more detailed, platform-specific instructions further down the page. Please bear in mind that the underlying system packages, which aren't mentioned here, may well differ between your desktop, your laptop, and whatever Linux servers you're using. If you're keeping all your own Python programs under version control, it would be wise to add this file to your saved set as a record of any support libraries you may have found necessary, and to keep it up-to-date. The requirements file documents your required set of extra packages in a near-executable form. Python3 -m pip install -upgrade -r ~/requirements-3.txt To add that set of packages into another virtual Python setup elsewhere, deactivate the old virtual Python, activate the new one (creating it if necesary), then saying in it: Python3 -m pip freeze -l | tee ~/requirements-3.txt The first part is done inside the virtual Python in question using: Virtual Pythons have absolute pathnames stitched in, so they can't be moved or copied as-is but they can be recreated without excessive effort. Which python3 # (should complain or return nothing) Which python # (should show the system Python) Note that the shell prompt has been changed back, as saying: If you wish (for whatever reason) to revert to using the system Python, exit from Python if necessary, then say (at the shell prompt): This will cause the script to use the first appropriate Python executable on $PATH, which (when it's active) will be the one in your virtual environment. ![]() To properly generalise such scripts, edit the first line to instead say: or some other variant which assumes you've installed some version of Python manually. In third-party Python scripts or examples, you may even see: This is Bad News: it hard-wires use of one particular Python interpreter (Apple's, or MacPorts's, respectively) into the program, which is likely to break portability. #!/opt/local/bin/python3 # (WRONG under Linux: macOS-specific) #!/usr/bin/python # (WRONG under macOS: system Python) Third-party Python scriptsĪ script intended to be invoked by name at the shell prompt may well have the "flash-bang" line at the beginning, to tell it which (in this case) Python interpreter to use, eg one of: and verifying that its pathname is within your virtual-Python directory. or (in PyRAF's case) by saying at the shell prompt: Pyraf._version_ # ('2.1.14' at the time of writing) Pyraf._file_ # (a pathname inside your virtual environment) You can then verify that your Python package has been installed by starting Python, and saying at its prompt: ![]() To install the PyRAF package into the virtual environment, activate your virtual Python and then: you'll see a Python instance named which is inside your virtual environment. Now check that the shell prompt has changed to reflect the change: ![]() Once the alias is set open a new shell and type the following to setup the python virtual environment. Data/usernme/myVirtualenv-3/bin/activate' bashrc: the middle of the line should read " -init='. 'source /Data/username/myVirtualenv-3/bin/activate.csh' cshrc: the middle of the line sbould read " -init 'source" (leave only one space). To simplify the startup process for the next time, you can add these aliases to your shell startup files, for use in subsequent shell sessions. Python3 -m pip install -upgrade pip setuptools wheel Setup your aliases to point to the virtual environment you have just created Source /Data/username/myVirtualenv-3/bin/activate (users of bash) Source /Data/username/myVirtualenv-3/bin/activate.csh (users of csh) Python3 -m venv -system-site-packages myVirtualenv-3 Create a directory in /Data/username/, replace username with the name of the account you are using:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |