[Help] Advanced tutorial: How to install my Python package with Virtualenv

133 views
Skip to first unread message

Aline C. R. Souza

unread,
Sep 27, 2016, 7:21:54 AM9/27/16
to Django users
Hello Guys,

I need some help to install my Python package with virtualenv. I follow the 'Advanced tutorial: How to write reusable apps' and moved the polls directory out of the project. Now I want to install my package using virtualenv and pip, but I don't know how.

Consider I am inside of my project diretory (where the manage.py is) and I am working on a virtual environment. What would be the right pip command to install my package, considering that the polls directory is out of the project.

Please help!




Bill Freeman

unread,
Sep 27, 2016, 1:27:41 PM9/27/16
to django-users
You don't say what OS/platform you are using, and I don't know if what I say below applies to Windows, but should be valid elsewhere.

Note, too, that I presume that you are using a command line (e.g.; xterm/bash).

I also presume that you have managed to install virtualenv on your system.

If  your virtualenv is activated (see virtualenv documentation), and you should activate it when working on your project, then just saying

   pip

should be enough.  Try saying

   which pip

if that works at all, it should report a pip withing the bin directory of your virtualenv.  On the other hand, if it reports the pip in a system directory, then your virtualenv has not been activated, or somethign is broken.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bb3167a4-61c3-4006-994d-c2b226636401%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gary Roach

unread,
Sep 27, 2016, 2:01:38 PM9/27/16
to django...@googlegroups.com
Hi

It took me a while to figure this  out but once you see it it is really fairly simple. It somewhat depends on what you are using for and IDE (Integrated Development Environment). I use Eclipse with PyDev plugin and like it.

Determine where you want to put your VE (Virtual Envirnment) . With Eclipse everything works out of the directory "workspace". Workspace can be anywhere on your system but, I find it works best in your home directory. If you are not using Eclipse then your working directory can be just about anywhere you choose.

Assuming that you have installed virtualenv or venv and virtualenvwrapper ( if on linux. Not sure about windows) you have a choice of what to do next. If you plan on using one of the standard text editors you will want put your whole project inside of the VE. If using something like Eclipse install the VE in a subdirectory in your workspace. Remember that the main purpose of a VE is to wall off packages such as Python and Django from the rest of your system. Use pip to install these packages into the VE using what ever versions are appropriate for your project.

If you are not using an IDE then you have your whole project inside the VE.Just turn on the VE  and you are set to go. If you are using an IDE then it depends on the IDE but generally you will reference the appropriate files in the VE when you set up your project. You do not have to activate the  VE under these circumstances. The VE is just a repository of the proper versions of the packages that you need for your project.

Hope this helps.

Gary R
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Message has been deleted
Message has been deleted

Aline C. R. Souza

unread,
Sep 27, 2016, 3:03:57 PM9/27/16
to Django users
Hello ke1g and gary719_list1,

Thank you for your time.

I am using windows and the cmd terminal. I do not know what you mean by activate the virtual env. I created one virtual enviroment called 'poll-tutorial' and used the command 'workon poll-tutorial' to work on this enviroment.

I think you didn't understand my doubt. I think I was not very clear. The thing is:


At the 'Using your own package' step, there is a choice:  install django-polls as a user library or with virtualenv

The tutorial does not explain how to install with virtualenv, so I am trying to figure it out.

I saw on a blog post that I should use the pip command as installing a user library but whitout the '--user':

pip install django-polls/dist/django-polls-0.1.tar.gz

But did not work, it can not find the file.

I think I am using this command at the wrong directory.

So, suppose that I am at 'mysite' directory, working on the 'poll-tutorial' virtual environment. What would be the correct pip command to install my package that is inside the folder django-polls/dist outside of 'mysite' directory?

I think my problem maybe is just about localization of the files. I am little bit lost.

ludovic coues

unread,
Sep 27, 2016, 3:13:22 PM9/27/16
to django...@googlegroups.com
the command 'workon poll-tutorial' translate to "source
poll-tutorial/bin/activate" on linux. That's why most user call it
"activating a virtualenv.

After your workon command, the terminal should display that you are in
the virtualenv workon. You can try "where pip" which should give you
the path to the command pip. The one in your virtualenv should be the
first one.

2016-09-27 21:01 GMT+02:00 Aline C. R. Souza <linec...@gmail.com>:
> Hello ke1g and gary719_list1,
>
> Thank you for your time.
>
> I am using windows and the cmd terminal. I do not know what you mean by
> activate the virtual env. I created one virtual enviroment called
> 'poll-tutorial' and used the command 'workon poll-tutorial' to work on this
> enviroment.
>
> I think you didn't understand my doubt. I think I was not very clear. The
> thing is:
>
> I followed this tutorial:
> https://docs.djangoproject.com/en/1.10/intro/reusable-apps/
>
> At the 'Using your own package' step, there is a choice: install
> django-polls as a user library or with virtualenv
>
> The tutorial does not explain how to install with virtualenv, so I am trying
> to figure it out.
>
> I saw on a blog post that I should use the pip command as installing a user
> library but whitout the '--user':
>
> pip install django-polls/dist/django-polls-0.1.tar.gz
>
> But did not work, it can not find the file.
>
> I think I am using this command at the wrong directory.
>
> So, suppose that I am at 'mysite' directory, working on the 'poll-tutorial'
> virtual environment. What would be the correct pip command to install my
> package that is inside the folder django-polls/dist outside of my project
> directory?
>
> I think my problem maybe is just about localization of the files. I am
> little bit lost.
>
> Em terça-feira, 27 de setembro de 2016 08:21:54 UTC-3, Aline C. R. Souza
> escreveu:
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fd24d7ee-3541-4707-b666-dc689b630ddd%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

ludovic coues

unread,
Sep 27, 2016, 3:16:12 PM9/27/16
to django...@googlegroups.com
Once you are working on a virtual environment, simply using "pip
install <package>" will install <package> in the virtualenv. No need
for an option.

Bill Freeman

unread,
Sep 27, 2016, 3:17:48 PM9/27/16
to django-users
I don't do development in Windows, so take this with a grain of salt, but under the directory in which you created your virtualenv, there should be a directory called "bin".  In that there will be a couple of files whose names begin with "activate".  There may be one with an obvious Windows extension, such as ".bat".  Try running that, which should leave you at a command prompt, possibly decorated with the name of the virtualenv (but that might be a *nix thing).  Your PATH environment variable probably will have been modified to include this directory early, so that the python executable there will be found first.  There is also a pip there, but I don't know if just typing "pip install package-i-want" will work, but typing "python pip install package-i-want" while cd'ed to that directory should.  There are probably ways to avoid having to cd to the directory.  Hopefully someone who develops on Windows can provide a better answer.

On Tue, Sep 27, 2016 at 3:00 PM, Aline C. R. Souza <linec...@gmail.com> wrote:
Hello ke1g and gary719_list1,

Thank you for your time.

Hi, I am using windows and the cmd terminal. I do not know what you mean by activate the virtual env. I created one virtual enviroment called 'poll-tutorial' and used the command 'workon poll-tutorial' to work on this enviroment.

I think you didn't understand my doubt. I think I was not very clear. The thing is:


At the 'Using your own package' step, there is a choice:  install django-polls as a user library or with virtualenv

The tutorial does not explain how to install with virtualenv, so I am trying to figure it out.

I saw on a blog post that I should use the pip command as installing a user library but whitout the '--user':

pip install django-polls/dist/django-polls-0.1.tar.gz

But did not work, it can not find the file.

I think I am using this command at the wrong directory.

So, suppose that I am at 'mysite' directory, working on the 'poll-tutorial' virtual environment. What would be the correct pip command to install my package that is inside the folder django-polls/dist outside of my project directory?

I think my problem maybe is just about localization of the files. I am little bit lost.


Em terça-feira, 27 de setembro de 2016 08:21:54 UTC-3, Aline C. R. Souza escreveu:

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Aline C. R. Souza

unread,
Sep 27, 2016, 6:17:15 PM9/27/16
to Django users
Hi everybody,

Pip was working, but I did not know how to use it. Now, I figured out. 

Inside the project directory: 

pip install ../django-polls/dist/django-polls-0.1.zip

Worked fine, the app is running.

Thank you, guys.


Em terça-feira, 27 de setembro de 2016 08:21:54 UTC-3, Aline C. R. Souza escreveu:

Luis Zárate

unread,
Sep 30, 2016, 8:24:23 PM9/30/16
to django...@googlegroups.com
You need to create a setup.py file (see setuptools doc) it's a simple file find examples. Then do

python setup.py sdist

This will create dist file then surft to the .tar.gz file

pip install -u django-poll.tar.gz

Or you also can do

python setup.py install
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/66dc1093-dced-4d3b-8a34-3e1c250fbee0%40googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.
>

--
"La utopía sirve para caminar" Fernando Birri



Reply all
Reply to author
Forward
0 new messages