Runnin pip from a python script that runs from jep using virtualenv

109 views
Skip to first unread message

Alejandro Kapit

unread,
May 14, 2018, 5:52:58 AM5/14/18
to Jep Project
I'm using JEP from Java to run a python script which actually installs (on demand) some new dependencies using pip.main.
And I'm running the my java application's Jar file after activating my virtualenv so that it will use a specific python environment.

However, I'm having kind of a weird experience, when my script actually runs:

pip.main(['install', '--user', package])

in order to install a non-existent package, it says that the dependency is already satisfied when I actually uninstalled it before running the script.

Could it be that pip inside of the script is running python from outside of the virtualenv? I'm confused.

How can I test this better?

Thanks in advance!



Nathan Jensen

unread,
May 14, 2018, 11:58:10 AM5/14/18
to Jep Project
Jep would hopefully pick up the virtualenv since you activated it before Java, but you may be the first person to try that.  When you import pip, try printing out pip.__file__ and see if it's picking up the virtualenv pip or the other/default Python's pip.

--
You received this message because you are subscribed to the Google Groups "Jep Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-project+unsubscribe@googlegroups.com.
To post to this group, send email to jep-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jep-project/fb614ce8-1621-4dbe-a94c-a7f4a584290a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alejandro Kapit

unread,
May 15, 2018, 5:11:28 AM5/15/18
to Jep Project
It's very stange, when trying to import a package it doesn't found it, so pip tries to install it , buen when trying to install it it says it's already satisfied...  some ideas?
Note: first line is the print of the pip.__file__ .

INFO:setup:/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/__init__.py
INFO:setup:Packages are: ['googleads']
INFO:setup:Importing: googleads
INFO:setup:Not found, trying to install: googleads
Requirement already satisfied: googleads in /usr/local/lib/python3.6/site-packages




On Monday, May 14, 2018 at 6:58:10 PM UTC+3, Nathan Jensen wrote:
Jep would hopefully pick up the virtualenv since you activated it before Java, but you may be the first person to try that.  When you import pip, try printing out pip.__file__ and see if it's picking up the virtualenv pip or the other/default Python's pip.
On Mon, May 14, 2018 at 4:52 AM, Alejandro Kapit <aka...@gmail.com> wrote:
I'm using JEP from Java to run a python script which actually installs (on demand) some new dependencies using pip.main.
And I'm running the my java application's Jar file after activating my virtualenv so that it will use a specific python environment.

However, I'm having kind of a weird experience, when my script actually runs:

pip.main(['install', '--user', package])

in order to install a non-existent package, it says that the dependency is already satisfied when I actually uninstalled it before running the script.

Could it be that pip inside of the script is running python from outside of the virtualenv? I'm confused.

How can I test this better?

Thanks in advance!



--
You received this message because you are subscribed to the Google Groups "Jep Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-project...@googlegroups.com.

Nathan Jensen

unread,
May 15, 2018, 12:36:29 PM5/15/18
to Jep Project
INFO:setup:/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/__init__.py

appears to NOT be using the pip that came with the virtualenv since I presume the printed out directory is not your virtualenv but instead the builtin Python 3.  That looks like a pip from the standard Python install.  So your idea of "Could it be that pip inside of the script is running python from outside of the virtualenv?" appears correct.

Did you install jep into the virtualenv?  Is that a possibility for your use case?  I think you're running jep from the builtin python but then trying to use a virtualenv for the installs of the new dependencies.  If you install jep into the virtualenv and then run it I think it would work.


To unsubscribe from this group and stop receiving emails from it, send an email to jep-project+unsubscribe@googlegroups.com.

To post to this group, send email to jep-p...@googlegroups.com.

Alejandro Kapit

unread,
May 15, 2018, 3:46:53 PM5/15/18
to Jep Project
Oh, that's a good point, I think I've installed jep from outside the virtualenv, just by specifing the python version, I think. 
I'll try!
Reply all
Reply to author
Forward
0 new messages