What is the best way to install packages on TeamCity server? - python

I am new to TeamCity and I do not know how to install packages I have imported in my python code on the TeamCity server. For example I have imported selenium in my code and tried to install it using command line on TeamCity by pip install selenium but I got the error pip: command not found. I am not sure this is the best way to install needed packages.

It seems like you don't have "pip" (Python package manager) installed on the machine that your Team City agent is running on. Team City does nothing but triggering your builds. In your case, it probably is only resolving dependencies (your Python packages) and running your code.
So you need to install pip on the machine that is running the Team City agent. (You might have multiple agents, install pip on all agents that might build this python project)
You might want to upgrade your Python. Python 2.7.9 and later already comes with pip. https://www.python.org/downloads/
Instruction on how to install pip.
https://pip.pypa.io/en/latest/installing.html
You can SSH to that machine and run the following bash script (assuming you are on UNIX).
$ curl https://bootstrap.pypa.io/get-pip.py >> get-pip.py && sudo python get-pip.py

Related

chocolatey says it has successfully force reinstalled python 3.11 - but I can't find it

Windows 11.
I am not great at virtual environments, and I have bumped around between a half dozen different "solutions." I thought I had it solved with chocolatey, but I am trying to install python3.11, and not having success. Basically, choco says it is installed, but I can't find it anywhere.
C:\Windows\System32>choco install --force python --version=3.11
Chocolatey v1.2.0
Installing the following packages:
python
By installing, you accept licenses for the packages.
python v3.11.0 already installed. Forcing reinstall of version '3.11.0'.
Please use upgrade if you meant to upgrade to a new version.
Progress: Downloading python 3.11.0... 100%
python v3.11.0 (forced) [Approved]
python package files install completed. Performing other installation steps.
The install of python was successful.
Software installed to 'C:\ProgramData\chocolatey\lib\python'
Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
C:\Windows\System32>
This gives the impression that python would be in C:\ProgramData\chocolatey\lib\python, but the only files in that directory are python.nupkgandpython.nuspec`
Where do I go to find my shiny new python?
From PowerShell, run get-command python.exe
And you will get something like this:
CommandType Name Version Source
----------- ---- ------- ------
Application python.exe 0.0.0.0 C:\Users\Paul\AppData\Local\Microsoft\WindowsApps\python.exe
The Source column is where it is running python.exe from and where python is installed.
The python package on the Chocolatey Community Repository is a metapackage. So it does not install python, instead, it has a dependency on python2 or python3 (depending on the version of python), that dependent package is what actually installs Python. So if you install python v3.11, that will have a dependency on python3 v3.11, and the python3 package will download and run the Python installer.
Instead of force installing python, try for installing python3 to rerun the Python installer.
As for the install location, packages install to $env:ChocolateyInstall\lib\. So the .nupkg, .nuspec, chocolateyInstall.ps1, etc will all be there. But the python3 package runs the Python installer, and the Python 3.11.x installer will by default install to C:\python311 when run by the chocolateyInstall.ps1 in the python3 package.

aws CLI install window

I am having trouble installing the aws CLI for windows.
I am following these instructions here
It requires that I have Python 3.6.2 but I have Python 2.7.6 when I run python --version
After I run
pip install --user --upgrade awscli
and then try to run
aws --version
nothing happens.
I tried setting my path in Environment Variables but it still won't work.
After this, I tried to upgrade my python version by installing python 3.6 on their website, but my python version won't update when I run python --version.
Could this be that start of why I cant install the CLI?
Use this link to download and install AWSCLI Download the AWS CLI MSI installer for Windows
then go to C:\Program Files\Amazon\AWSCLI or where-so-ever you have installed this and set the path in Environment variables.
Cheers!
Have you gone through the steps on the amazon website? Python 2 and 3 are quite different from what I understand.
https://docs.aws.amazon.com/cli/latest/userguide/installing.html
The AWS script you are running is really just a python program. I recommend verifying install paths, and possibly use their bundled installer found on the page above, about half way down.
At first make sure you have installed python3. Check it with command:
Try to verify python version with command(on centos or redhat):
$ rpm -qa|grep python3
And then make sure python3 has been added to $PATH
$python3 --version
And I think you need to install pip3 for python3.X.
$yum search python3|grep pip
And then install the package you need with command
$ pip3 install --user --upgrade awscli
You can develop Python software for AWS in both Python 2.x and 3.x. The CLI is written in Python 2.x.
You can have both Python 2 and Python 3 installed on your system. You can either specify the python.exe manually using its full path (not recommended but I do this all the time) or by updating your environment PATH variable to point to the correct Python installation. I use a batch file so that I can switch back and forth between Python 2 and Python 3.
When you run "pip install --user --upgrade awscli" the version of Python that is running determines the awscli package that is downloaded and installed.
For Microsoft Windows, AWS provides an MSI installer package that contains everything that you need including the correct version of Python 2.7. I recommend that you start with the AWS Windows MSI and then learn how Python works (environment) on Windows.
Keep in mind that Python 2.x is going away. This is not official but plan for January 1, 2020 as the drop dead day. This means where possible develop for Python 3. IMHO it is time to stop developing for AWS in Python 2.x.
If you have choco installed the following will work....
choco install -y awscli
$env:Path += ';C:\Program Files\Amazon\AWSCLI'

Install a Python package that built for Windows and MacOS on Linux

I have currently used the python Package Larch (https://pypi.python.org/pypi/larch) on Windows. It works nicely and I am really impressed with its performance. To use the package with some large models I want to install it on a Linux server (Ubuntu 14.04.4) where I do not have the root permissions. Though knowing that the OS requirements for the package are Window or MacOS and being a beginner with Linux, I still gave it a try.
I was able to install python locally using anaconda distribution but when I used pip to install larch, I got the following message
Could not find a version that satisfied the requirement larch (from version: )
No matching distribution found for larch
So it seems to me that I can not just deliberately try to install the package on linux with out any additional work. I then tried to find solutions for my issue but I could not find any. Therefore I would like to ask if there is any workaround for my problem?
Thank you so much for your help!
[Edit]
larch does not support python2.x, and only support Windows, MACOSX.
For installing in Linux, I suggest to use wine to run windows python program with larch.
For more information about wine in Ubuntu. You can search with keyword such as How To Run Windows Software on Ubuntu with Wine
For installing in macosx. Making sure your environment have python3. You can use which python3 to check that.
$ which python3
/usr/local/bin/python3
Then, without root permission, you can install package via virtualenv. (A workstation should provide this command)
$ virtualenv -p $(which python3) env
$ . env/bin/activate
(env) $ python -V
Python 3.x.x
And finally, you can install larch via pip.
(env) $ pip3 install larch
For more information about virtualenv
"Larch can be installed from source code. If not using Anaconda, this is necessary for Linux, and can be done for other systems as well.
The latest releases of the source code will be available from Larch releases (github.com). In addition, you can use git to grab the latest development version of the source code:git clone http://github.com/xraypy/xraylarch.git" After unpacking the source distribution kit, installation from source on any platform is:
python setup.py install
source:http://cars.uchicago.edu/xraylarch/installation/index.html
edit: See this for doing this without root access
How to install python modules without root access?

Running and installing missing modules for script through SSH

I want to run a python script on a Linux Box(I'm connecting to it through SSH on OSX terminal). In order for this script to run, the computer must have the SUDS module installed. I was wondering what would be the best way to install SUDS on computers that run my script and do not have SUDS installed in them. My script is in a folder the has a virtual env. The structure of my folder is:
MainFolder
-------script.py, env folder
|----------binFolder, includeFolder, libFolder
Should I code my script to install SUDS from the script itself?Or is there a better method to achieve this?
Also, I would like to know if there's a way to run my virtualenv through the SSH and use pip to install in the Linux Box?
Well it depends if you are deploying it only on this server and do not want to distribute the code than you would have to run the following command (assuming you have pip and python-tools)
sudo pip install SUDS
but if you get an error back saying that the command pip is not installed you will need to run the following command
sudo apt-get install python-pip python-dev build-essential
If you want to distribute it than I would do open source on github
with the instructions of how to use the program and run it I would add a dependencies list of all the external modules you used for your script.
Hope this helped.

How to install Pip on compiled from source Python

I'm on a raspberry pi running the latest Debian. It comes with 2.7.3 by default but I bought it to run a large Flask home automation app which was all written on 2.7.9 and I want no problems later on ( I know it is a minor version but I am a perfectionist).
So I downloaded the latest Python 2.7.10. And did
./configure && make && make altinstall
So far so good. It has installed the interpreter under /usr/local/bin as I expected. Now I need to to be able to run pip install -r requirements.txt, then I need pip. So I downloaded the get-pip.py from the Python website and tried
/usr/local/bin/Python2.7 get-pip.py
With no luck. I have also tried to create a virtualenv with a different my compiled Python interpreter like
virtualenv -p /usr/local/Python2.7 venv
No luck either. I was able to install easy_install on my compiled Python but it also throws me an error when I try
/usr/local/bin/easy_install pip
What am I doing wrong? I have read about --ensurepip flag for configuring Python at the first place, but Do I need to remove Python and install it all over again just to have pip on my compiled interpreter?
I was facing the same issue. I resolved it by appending an extra parameter to the configure command --with-ensurepip=install followed by make and make install. Then, my installation folder for python has pip there in.

Categories