Sometimes you need to build an environment when you cannot connect to the Internet and you must use the previous environment because your code needs to run in the same environment. This is convenient for development
Method 1:
1.Download the specified package to the specified folder。 pip list #View installed packages pip freeze > Will have passedpipThe name of the installed package is recorded to In the file Create a directory where the installation package is stored:mkdir /packs pip install --download /packs pandas(Store onepandasBag) or pip install --download /packs -r (存放列出的所有Bag) 2.安装指定的离线Bag pip install --no-index --find-links=/packs/ pandas or pip install --no-index --find-links=/packs/ -r (It may also be --find-link)
However, this method will have many problems after testing it myself. For example, in pip install --download /packs -r, this operation may cause some packages to be unable to download, and after downloading the package, the installation may be missing dependencies on the new server. The installation may not be successful.
Method 2:
That is to use the integrated environment - Anaconda. This installation is super simple, because this is a packaged environment. The python third-party packages you download and install later are all in this environment. In this way, you just need to copy the installed Anconda package to an unnetworked server (of course, it needs to be configured on .bashrc).
Step 1 Now install Anaconda:
Download the Anconda installation package from the official website. Here I am using Anaconda3-5.2.0-Linux-x86_64.sh.
bash Anaconda3-5.2.0-Linux-x86_64.sh
Enter, Y, and then remind you to configure the environment
echo 'export PATH="/home/wwk/anaconda3/bin:$PATH"' >> ~/.bashrc
source .bashrc
Of course, you can also choose the installation path in the middle. Generally, it is OK to choose the default. Now verify whether the installation is successful.
conda -V
If the version number appears, it will be successful.
The second step is to install the package you need:
Anconda integrates pip and conda. Of course, both of them can download various packages. pip isntall somepackage, conda install somepackage, but a problem may occur when downloading with the conda command. The installation package you need may not hit (because the domestic mirror channel may not be found). Take the py2neo package as an example.
wwk@wwk-Aspire-V3-572G:~$ conda install py2neo Fetching package metadata ............. PackageNotFoundError: Packages missing in current channels: - py2neo We have searched for the packages in the following channels: - /anaconda/pkgs/free/linux-64 - /anaconda/pkgs/free/noarch - /pkgs/main/linux-64 - /pkgs/main/noarch - /pkgs/free/linux-64 - /pkgs/free/noarch - /pkgs/r/linux-64 - /pkgs/r/noarch - /pkgs/pro/linux-64 - /pkgs/pro/noarch
Then we have two ways:
1. The most direct way is to download the installation package we need directly from other channels, such as downloading zip from github, and then decompressing the compressed package and enter the decompression directory. Use the python install command to install (note that at this time, which python needs to check whether the environment is in anconda, so as to ensure that it is installed in anconda environment). In fact, it can also be installed directly (anconda embedded) and is more convenient.
2. Then the problem that appears above is solved, enter: anaconda search -t conda py2neo
wwk@wwk-Aspire-V3-572G:~$ anaconda search -t conda py2neo Using Anaconda API: Packages: Name | Version | Package Types | Platforms | Builds ------------------------- | ------ | --------------- | --------------- | ---------- auto/py2neo | 1.6.4 | conda | linux-64, linux-32 | py27_0 : /py2neo bioconda-legacy/py2neo | 3.1.2 | conda | linux-64, osx-64 | py36_0, py27_0, py35_0, py34_0 cmckeague/py2neo | 3b1 | conda | linux-armv7l | py27_0 : Python client library and toolkit for Neo4j conda-forge/py2neo | 4.0.0b2 | conda | linux-64, win-32, osx-64, win-64 | py36_0, py35_0, py27_0 : Python client library and toolkit for Neo4j ivoflipse/py2neo | 1.6.4 | pypi, conda | win-64 | py27_0 : Python client library for the Neo4j REST server mutirri/py2neo | 2.0.8 | conda | linux-64, win-32, win-64, osx-64 | py27_0, py33_0, py35_0, py34_0 : Python client library and toolkit for Neo4j Found 6 packages Run 'anaconda show <USER/PACKAGE>' to get installation details
Then enter: anaconda show conda-forge/py2neo and you can see the channel you want to install the package
wwk@wwk-Aspire-V3-572G:~$ anaconda show conda-forge/py2neo Using Anaconda API: Name: py2neo Summary: Python client library and toolkit for Neo4j Access: public Package Types: conda Versions: + 4.0.0b2 + 3.1.2 To install this package with conda run: conda install --channel /conda-forge py2neo
According to the prompts on the last line, we can copy it and enter it
wwk@wwk-Aspire-V3-572G:~$ conda install --channel /conda-forge py2neo Fetching package metadata ............... Solving package specifications: . Package plan for installation in environment /home/wwk/anaconda3: The following NEW packages will be INSTALLED: neo4j-python-driver: 1.1.0rc1-py36_0 conda-forge py2neo: 4.0.0b2-py36_0 conda-forge The following packages will be UPDATED: conda: 4.3.30-py36h5d9f9f4_0 /anaconda/pkgs/free --> 4.5.11-py36_0 conda-forge conda-env: 2.6.0-0 /anaconda/pkgs/free --> 2.6.0-1 conda-forge Proceed ([y]/n)? y conda-env-2.6. 100% |#####################################################################| Time: 0:00:00 1.34 MB/s neo4j-python-d 100% |#####################################################################| Time: 0:00:00 72.70 kB/s py2neo-4.0.0b2 100% |#####################################################################| Time: 0:00:00 176.24 kB/s conda-4.5.11-p 100% |#####################################################################| Time: 0:00:02 230.86 kB/s
Finally, don’t forget to open the Python environment import package and try it out, whether it is successful.
The above operations are to fully arrange your operating environment in an environment with network. Then congratulations, you have completed 99%
Step 3: Compress and package the installed anconda3 and copy it to the unnetworked server you want to install. I put it in /home/wwk/anaconda3
at last:
unizp -d /home/wwk/anaconda3
vim .bashrc # added by Anaconda3 installer export PATH="/home/wwk/anaconda3/bin:$PATH"