LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to force Python to use newest version of package (https://www.linuxquestions.org/questions/programming-9/how-to-force-python-to-use-newest-version-of-package-4175622479/)

intmail01 01-26-2018 02:01 PM

How to force Python to use newest version of package
 
Hi,

I install a python application which required several packages. I am not a python programmer and use command
Code:

python setup.py install
for each package.

After installing all needed packages, the main application dont find them and expect the isntallation of exact version. I downloaded and installed the most recent version for all required packages.

I dont want to download again. My question is how to force the installation process to use the newest version that I have already installed.

Thanks

hydrurga 01-26-2018 02:37 PM

Here's the relevant page on installing Python packages:

https://packaging.python.org/tutoria...ling-packages/

I usually use pip to install my Python packages and it works well.

Note that if you are using a distro which has both Python2 and Python3 installed, you will need to use pip3 for Python3 packages. For my Linux Mint setup, I usually use sudo -H pip3 when calling pip3 but your mileage may vary depending on your distro.

dugan 01-26-2018 02:43 PM

If you're describing what I think you're describing: there's a metadata file in the "main application" that describes which versions of which dependencies it needs. To get "the main application"'s setup scripts to tolerate the versions you have installed, you would edit "the main application"'s metadata files.

The metadata is described here:

https://svn.python.org/projects/sand...oc/formats.txt

Obviously, this is not a good idea. ;) It will result in an unsupported, untested setup for "the main application".

If "the main application" includes a file called "requires.txt", then you could have installed the correct versions of all its dependencies with:

Code:

pip install -r requires.txt
And if "the main application" is on pypi, then you could have installed it and the correct versions of all its dependencies with:

Code:

pip install <name of main application>
You chose not to name or link to "the main application", so this is as specific as I can get.

Sefyir 01-26-2018 07:19 PM

Try running this in the terminal:
Code:

python -c 'import sys; print("\n".join(sys.path))'
sys.path is the directories python will examine to see if there is a module to import.

Did the setup.py tell you where it installed it to? Did it install it to any of these directories?

dugan 01-26-2018 07:26 PM

@Seyfir: it sounds like the "main application" was a Python wheel, and it refused to install because he'd installed the wrong versions of its dependencies.

Sefyir 01-26-2018 07:54 PM

Didn't even know what wheels are, but there they are.
After looking at the PEP, wheel files shouldn't even include a setup.py? Going off of that, it seems like a python setup.py install command should fail
Trialling the simplejson wheel didn't reveal any setup.py file.

Quote:

Wheel does not contain setup.py or setup.cfg.
Wheels are completely new to me, so I may be off on the above.

dugan 01-26-2018 09:28 PM

No, he only said he installed the dependencies using setup.py.

He didn't say how he tried to install "the main application". If he tried to install it with "pip install /path/to/main_application.whl", then it will check dependency versions and refuse to install if they're wrong.


All times are GMT -5. The time now is 01:32 PM.