Working with django-pagedown - python

I am following the instructions on the official Django-pagedown repo
pip install django-pagedown - installed without errors
Add pagedown to your INSTALLED_APPS - error thrown is "ModuleNotFoundError: No module named 'pagedown'
3.Collectstatic run smoothly.
When I check the modules currently in my virtual env using help('modules'), pagedown was not present, but in my global installation of python, it was present, so my question is, why can't my project work/use the present installed django-pagedown installation? what am I missing here?
python - 3.6.4
django version - (2, 0, 4, 'final', 0)
pip version - 10.0.1
os - windows

The package is actually installed in your computer, as you can see it presents in the global installation. Just because you didn't activate the virtual environment that you use.
Go to your project, activate the virtual environment (scripts\activate).
Make sure that you see the name of your virtualenv shown before the path like that (env_name)C:\Users\....
Then run pip install django-pagedown.

I figured out the problem and it was pip, somehow while running the command pip install django-pagedown in my IDE, (and running in my virtual env), it was installing pagedown globally and missing in my virtual env, so, I just changed IDEs and that's it. Thanks all for helping me out.

If the package is installed globally, and the virtualenv is setup such that it doesnt look into your global packages, then this issue can occur.
You need to either install the package using the pip command after activating the virtualenv or maybe run the project without the virtualenv ( in this case you will also need to have other dependencies to be installed globally)

Related

pycharm don't see things installed with pip

From the start of using pycharm i am facing problems with working with libraries
I tried reinstalling python, pip, pycharm; adding and readding to path. I also tried using pipenv instead of virtenv.. and it worked once, but.. now again-
i use $pip install numpy |as example| in cmd window it says to be successfully installed. Go to pycharm, type 'import numpy'.. and nothing happens. I know i can download manually: go to settings and so on.. but it would be much beter if pip installed with cmd would be instantly displayed in Pycharm. Anybody, please, help.
Check if you have activated the virtual environment in which you have installed the packages. For instance you may have installed the package on Global python version and running your program on a virtual environment which will not work. So maybe try activating your virtual environment before installing the Packages.
Step 1:-
activate {name_of_pipenv}
pip install numpy

Why does ubuntu end up with different versions of python and pip and django gets installed globally instead of in the virtualenv?

I'm trying to learn Django and I installed ubuntu bash on Windows to use it there. As ubuntu comes with Python preinstalled but not pip, I installed pip and updated it. However, when I use pip3 -V it shows the past version of pip. There are two pip installs and I can't figure out how to upgrade the one that Python uses. I also installed Django when I was already inside the virtualenv but it was installed globally, so I guess this is because of the same problem.
Does anyone know how can I have just one python and one pip installed to avoid those issues? I reinstalled ubuntu because I got really annoyed...
Addiing venv to path is not the correct way to work in a venv you have to source bin/activate and use pip not pip3 since there the correct pip is loaded automatically. Ides source venv automatically when opened in the project directory. This allows to have a clean environment for each project
I already solved it, adding to PATH the path of the other pip, thanks to the guys who answered.

pip-installed package inside conda virtual environment is not isolated

I am developing a simple python package (on macOS 10.14) and I have problems in setting the instructions how to install it. Right now the package is not available anywhere yet, but think of it as a dummy "hello world" package with a dummy "hello world" function inside a dummy "hello world" module. Of course it has a proper setup.py script that would allow users to install and uninstall the package with pip.
When I install and test it myself everything works fine, the problem is not related to the package itself.
The issue is that I cannot make conda virtual environments and pip work together... Next to my setup.py script there is a environment.yaml file that specifies the dependancies required for my package. Based on this file I create a virtual environment with:
conda env create --prefix ENV -f environment.yaml
I have conda 4.7.12 with Python 3.7.3 inside so the virtual environment has it's own pip. So I activate the virtual environment and explicitly call the pip inside to install my package in the virtual environment:
/Users/my_name/Desktop/dev_dir/ENV/bin/pip install . --user
The installation is successful and the package can be imported. However when I deactivate the virtual environment with conda deactivate and run python interpreter from the conda base environment (version 3.6.9) I can still load my package! For some reason it is available outside of that particular virtual environment...
Later, when I run the 'inner' pip from conda base shell:
/Users/my_name/Desktop/dev_dir/ENV/bin/pip uninstall pkg
The removal seems to go through as well. I get a message:
Uninstalling pkg-0.0.0.9000:
Would remove:
/Users/my_name/.local/lib/python3.7/site-packages/pkg-0.0.0.9000.dist-info/*
/Users/my_name/.local/lib/python3.7/site-packages/pkg/*
Proceed (y/n)? y
Successfully uninstalled pkg-0.0.0.9000
suggesting that the package was indeed installed in a directory .local, outside conda virtual environments.
And the best for the last: even after this uninstallation when I run python interpreters (regardless of which environment from) and I try to import pkg it still works! when I then type pkg in the interpreter I get the path to my development directory:
>>> import pkg
>>> pkg
<module 'pkg' from '/Users/my_name/Desktop/dev_dir/pkg/__init__.py'>
Could someone please help me disentangle this mess? I would like to have my package installed inside the virtual environment, nicely isolated. And also - it should be gone after uninstallation, right?
PS. PYTHONPATH variable is never set anywhere at any stage, I have been checking that...
when I then type pkg in the interpreter I get the path to my development directory
This can only happen if:
You modified your PYTHONPATH to include /Users/my_name/Desktop/dev_dir which you didn't do
You are running the interpreter while you are in the folder /Users/my_name/Desktop/dev_dir, seems likely as you called it your development folder.
Check the output of print(sys.path), which lists all directories that are searched when doing import (standard locations + PYTHONPATH) and also print(os.getcwd()) as the current working directory is also searched
You tried installing your package to your activated conda environment using
/Users/my_name/Desktop/dev_dir/ENV/bin/pip install . --user
Looking at [the docs](https://pip.pypa.io/en/stable/reference/pip_install/#cmdoption-user] however:
--user
Install to the Python user install directory for your platform. Typically ~/.local/
So the --user option is messing with your intention to install into the currently active environment. But pip actually does that by default when run inside a virtual environment. So simply do:
conda activate <your envname>
pip install .
#FlyingTeller already correctly identified the issue. I just wanted to point out that you could further streamline your process by adding the installation for your package into your YAML definition. For example,
name: my_env
channels:
- defaults
dependencies:
- python=3.7.3
- pip
- pip:
- -e /Users/my_name/Desktop/dev_dir/pkg
This is also further in line with the best practices (see "Using Pip in a Conda Environment").
Just wanted to hopefully clear some up by telling you this keeps happen to many and if you forget the rule that is NO root install with conda, all rules for your files might change and suddenly it keeps asking for sudo AND fails. Conda = NO SUDO! Hope you got it fixed!
You have to add the pip package to your environment (see https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html), otherwise the packages will be installed by the global pip installation such that those packages can be accessed by all environments.
Therefore, create an environment using
conda create --name exampleenv pip
instead of
conda create --name exampleenv

Macport Portfiles do not work in Virtualenv

I have installed PyQt4 through Macport sudo port install py27-pyqt4 and virtualenv with pip install virtualenv. Whenever I run my PyQt programs while i am in the virtual environment I would receive the following error:
ImportError: No module named PyQt4.QtGui
However, I am able to run the same application when I am out of the virtual environment. What could be the reason for this issue and how do I resolve it?
Looks like you may have not installed PyQt4 into the virtual environment, usually the steps are as follows:
1) Create a virtual env: virtualenv ve_name
2) Activate the created virtualenv: source path_to_ve_name/bin/activate (at this point your shell will get ve_name prepended to it, and your $PATH will get updated, so whatever you install via pip will end up going into path_to_ve_name/bin)
3) Install all the dependencies while keeping ve_name active: pip install package-name, etc.
Once you have done this, you need to install PyQt4 into that virtual environment, there's an example here: How to install SIP and PyQt on a virtual environment? It looks like a simple pip install doesn't work with PyQT, so check out the suggestions in that question.
When you are done dealing with ve_name, you just need to deactivate your virtual environment (using command deactivate from your shell). This will revert your $PATH variable, and you can either create a new ve for a new project, or resume working on the same project by reactivating the created ve.

pip-python not found within virtual environment

I've installed python-virtualenv and python-virtualenvwrapper, and created a virtual environment by using mkvirtualenv NAME, and then activated it through workon NAME. By looking in ~/.virtualenvs/NAME/bin I see that pip is installed there.
However, when I try and install anything through pip, I'm told pip-python: command not found
I have not installed pip system wide, and was under the impression that I did not need to, given that it was already installed inside the virtual environment. Now, all this leads me to believe that something is not being set correctly with my $PATH, what could that be though? Once I'm in side the virtual environment as such: (NAME)[user#host]$ shouldn't my path already be modified to use the pip installation inside that environment? What do I need to do to make this so?
You must install pip on you system to make it accessible in virtualenv.
pip-python is the name of the executable in some Linux distributions. It is on my Fedora machine.
When pip is installed in a virtualenv, the name of the executable is simply pip, not pip-python. So you need to execute it with ~/.virtualenvs/NAME/bin/pip, not ~/.virtualenvs/NAME/bin/pip-python.

Categories

Resources