Coder Social home page Coder Social logo

berserk module not found about berserk HOT 2 CLOSED

sentrworks avatar sentrworks commented on July 17, 2024
berserk module not found

from berserk.

Comments (2)

sentrworks avatar sentrworks commented on July 17, 2024 1

Brilliant! Your first option which is forcing pip to target python3.6 worked pretty well. In addition to your suggestion, I had to use one more prerequisite step to get pip module first for python3.6.

  1. curl https://bootstrap.pypa.io/get-pip.py | sudo -H python3.6
  2. python3.6 -m pip install berserk

The Berserk is a fabulous 🥇 package within both its name and functionality, now I do not need to develop another parser with BeautifulSoup (I hope :)

cheers 👍

from berserk.

rhgrant10 avatar rhgrant10 commented on July 17, 2024

So pip and python can be confusing sometimes. I think what's happening here is that you're using the wrong pip to install the dependency. Note that when you run pip3 install berserk it prints out that lots of requirements are already satisfied but the paths are for a python2.7/site-packages directory. Obviously, something isn't right there. Two things can help to avoid these problems: virtual environments and python module execution.

Let's talk about python module execution first. Python provides a -m flag that accepts a module name as an argument and invokes the module as a program. The syntax is

<PYTHON> -m <MODULE_NAME> [<ARGS>...]

Notable examples are the HTTP server for serving the current directory of files over some port and the JSON module for pretty-printing:

$ python2.7 -m SimpleHTTPServer 8000
$ python3 -m http.server 9000  # module is different for python3
$ echo '{"foo": "bar", "baz": "qux"}' | python -m json.tool
{
    "baz": "qux",
    "foo": "bar"
}

Because pip installs packages to a specific python version, I always recommend running pip as a module because it forces you to invoke it with a specific version of python:

$ python3.6 -m pip install berserk
$ python2.7 -m pip install berserk

Using this method, there's no ambiguity or confusion as to which python's site-packages directory will be used for installation.

Secondly, virtual environments are a tool for creating isolated python environments and are highly recommended both when developing or hacking on packages and when deploying to a production machine. There are many tools out there for creating environments (read up on virtualenv, pyvenv, tox, and pipenv), but here's how I would create one to work on berserk:

$ python3.6 -m venv env
$ source env/bin/activate
[env] $ pip install berserk

A couple of things to note here. Firstly, I create the environment using the venv module through a specific version of python (3.6 in this case) to avoid any confusion. Secondly, after I create the environment I "activate" it. This changes my sys path so that when I run python I get the specific version of python used to create the virtual environment. It also makes pip refer to the specific version of pip that will install packages to the site-packages directory of the python for my virtual environment. That is to say, once my virtual environment is activated, python and pip are the right python and pip without having to worry.

tl;dr: use virtual environments to isolate installations from each other and system python. Use module execution when outside of a virtual environment to remove any ambiguity.

Last tip: you can invoke the site module to see which directories it checks for installed packages:

$ python3.6 -m site
sys.path = [
    '/Users/rhgrant10/code',
    '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
    '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
    '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
    '/Users/rhgrant10/Library/Python/3.6/lib/python/site-packages',
    '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages',
]
USER_BASE: '/Users/rhgrant10/Library/Python/3.6' (exists)
USER_SITE: '/Users/rhgrant10/Library/Python/3.6/lib/python/site-packages' (exists)
ENABLE_USER_SITE: True

Let me know how you get on :)

from berserk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.