Install non-conda packages in Anaconda on air-gapped machine - python

Trying to get pyNastran onto an air-gapped machine with a new install of Anaconda.
I've tried conda install pyNastran-0.7.1.zip on the zipped source code, and conda install setup.py inside the unzipped folder. Both commands cause conda to try to get "package metadata" from https://repo.continuum.io/pkgs and fail when they can't reach the server, despite this being the method suggested here.
python setup.py install fails due to setuptools not being installed, and installing setuptools through python fails, apparently due to setuptools not being installed (?!).
I must be doing something wrong here. How do I get this to install?

conda can only work with tar.bz2 files.
So, unzip pyNastran-0.7.1.zip and re-zip as pyNastran-0.7.1.tar.bz2 using some zipping tool.
Now, you need to tell conda to work offline with --offline:
conda install --offline pyNastran-0.7.1.tar.bz2

Related

Manual install of python module repo

I'm trying to install the package seen in these places: github, conda-forge, or pypi
So far I've tried a number of commands (NOTE: using windows, and anaconda prompt as administrator. You can see console output I posted here):
pip install git+git://github.com/dls-controls/cothread
conda install cothread
conda install -c conda-forge cothread
conda install -c conda-forge/label/cf202003 cothread
But in all cases, it's either PackagesNotFoundError: The following packages are not available from current channels: or fatal: unable to connect to github.com: github.com[0:140.82.113.3]: errno-Unknown error.
Now, I'm thinking I'll try a manual git clone, then go to the install folder and run pip install setup.py or python setup.py install. (something I think sounds good, but haven't done before) But I'm not sure where the proper place to clone it is. I'd like to add it to my anaconda environment named py310 (it's running 3.10.2). Does pip install automatically move a copy of it for me to the correct location? I want to do this right so that I keep some order to my configuration, and to help ensure that it's minimally confusing should I have to address some version issue in the future.
Thank you for any and all help!

How to pip install GDAL on Python 3.6 venv

gdal is correctly installed on my global system's python 3.5 packages.
But now I'm trying to pip install gdal on my python 3.6 virtual environment, but I receive multiple errors.
After activating the virtual environment, I've tried the following:
pip install pygdal or pip3 install pygdal
Error received: ERROR: Failed building wheel for pygdal
Tried following this guide, but the commands stated there are outdated
I've also tried this solution and this which failed
Installed older gdal versions but also didn't work.
Tried pip3 install GDAL==$(gdal-config --version) and I get the same error
I use
Ubuntu 16.04 and pip 21.0.1. Venv was created using virtualenv --python=/usr/bin/python3.6 my_venv
I've finally fixed the problem, and these are the steps I followed:
I uninstalled wheel from my venv
Then I pip installed gdal on the venv to check what error would appear
A wall of error text appeared, in which somewhere I noticed the 'x86_64-linux-gnu-gcc' failed with exit status 1
I typed sudo apt-get install python3.6-dev to install missing packages, as the solution suggests here
Then I ran pip install GDAL=<version that appears on ogrinfo --version> and it worked
EDIT: This answer pertains more to Windows than Ubuntu, but may have something useful.
Try downloading a wheel from here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
Note the "cp##" in the middle - that should match your Python version. If you are running Python 3.6 then you should see "cp36" in the file name (a "cp37" in the name means the wheel will fail). Also pay attention to the amd64 and win32 to be sure you have the correct version to match your Python virtual environment.
I'm on Windows instead of Ubuntu, but this was my process:
Open command prompt with cmd
Copy the path to activate.bat in the virtual environment from Windows Explorer (hold shift down, right-click on file, choose
"copy as path")
Paste path into control panel and hit enter. You should see an indicator that you are in virtual environment.
Copy the path to the wheel you downloaded to the clipboard using the same shift key trick.
Type 'pip install ' then paste the wheel path from your clipboard (or type it all out manually)
As an aside, I ended up with gdal installed within the osgeo module. I tried several things before I got here, but I'm pretty sure that happened with my installation from the wheel. In Python, I now use
from osgeo import gdal
I hope something here helps you. I've run into this a few times and it never seems like I quite remember how I got it done the next time I run into it. If I remembered it right this time, I can refer back here.
FWIW - I am using PyCharm and installing gdal through the Project Interpreter doesn't work. Also, it may take some jostling in PyCharm for the skeletons to update after you install through command prompt.

Python- can't install non-conda package

I installed anaconda2-4.4.0 in path /opt/anaconda and add it as my Pycharm interpreter and all things went well until I needed to install non-conda python package in this link. I installed it using pip command and it was in my Python packages using command pip list, But the problem is that package was not included in Conda, as I checked using command conda list and I couldn't import it in my project that uses anaconda as Python interpreter as well.
I try installing my package offline using command conda install --offline Downloads/hazm-master.tar.bz2, But it was errorful.
KeyError: Dist(_Dist__initd=True, channel=u'<unknown>', dist_name=u'hazm-master', name=u'hazm', version=u'master', build_string=u'', build_number=0, with_features_depends=None, base_url=u'file:///home/soheil/Downloads', platform=None)
How can I add my desired package on anaconda packages?
You need to call pip to do that. So what should work is
Conda.add("pip")
pip = joinpath(Conda.BINDIR, "pip")
run(`$pip install -e 'git+https://github.com/sobhe/hazm`)
On windows is might be
pip = joinpath(Conda.SCRIPTDIR, "pip")
# On UNIX, Conda.SCRIPTDIR == Conda.BINDIR
EDIT
However; You can also catch up this link to install the non-conda packages(Thanks to #Sraw's assistance)

Uninstall python package installed with `pip install --egg`

I installed SCons with pip install --egg scons. Now I want to uninstall it, but pip tells me that there is no package named scons, even though I can still call it from the command line. What is the proper way to remove it?
It happened to me as well. I think you tried pip install --egg scons since the normal way of installing gives you an error as discussed here.
Now to your problem, pip install --egg <package> spreads across installed files into the virtual-environment directory. I found this by running find -name *scons* in my virtual-environment directory:
./lib/scons-2.4.1
<lot of files>
./lib/scons-2.4.1/SCons/compat/_scons_io.pyc
./lib/python2.7/site-packages/scipy/lib/lapack/scons_support.py
./lib/python2.7/site-packages/scipy/lib/lapack/scons_support.pyc
./lib/python2.7/site-packages/scipy/lib/blas/scons_support.py
./lib/python2.7/site-packages/scipy/lib/blas/scons_support.pyc
./man/man1/scons-time.1
./man/man1/sconsign.1
./man/man1/scons.1
./bin/sconsign-2.4.1
./bin/scons-time-2.4.1
./bin/scons-2.4.1
./bin/sconsign
./bin/scons-time
./bin/scons
Deleting <virtualenv>/lib/scons-2.4.1, <virtualenv>/man/man1/scons* and <virtualenv>/bin/scons* should remove the installation.

How to install 3. Party library into anaconda if it is not in conda list

I have a general problem about module importation. Thank you very much.
The situation is the following:
I have a python compressed package *.tar.gz
This package can not be found in conda list
if I uncompressed it and use 'python setup.py install' package do would be installed into system python namely user/local/lib/python 2.7/site-packages, but anaconda distribution, which causes a problem that if I start python in anaconda distribution this installed package can not be accessed to.
So is there any direct solution to this problem?
Secondly, I am confused what's the difference between ~anaconda/env and virtualenv
thank you very much
First confirm that which python returns anaconda's installation of python and then just do:
$python setup.py install --prefix=/path/to/anaconda_directory/
Unzip the *tar.gz and place the file folders into the directory Anaconda\Lib\site-packages
You should use pip to do this: pip install <path_to_file>.
Alternatively, if your package is available on PyPi - you can just do a pip install <packagename> (do a pip search <packagename> to see if its on pypi.
For instance, I wanted to install pymongo - was easy - pip install pymongo.
Caveat:
I installed anaconda as root into /opt/anaconda - so, I had so sudo su, the add /opt/anaconda/bin to the start of PATH, then run pip install pymongo so that it would install the package into the anaconda dist, and not the existing ubuntu python dist.

Categories