Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with initialise.py #166

Open
6oncv1o opened this issue Dec 20, 2021 · 1 comment
Open

Problem with initialise.py #166

6oncv1o opened this issue Dec 20, 2021 · 1 comment

Comments

@6oncv1o
Copy link

6oncv1o commented Dec 20, 2021

Hey guys,

I was going to start doing a bunch of exercises about numpy and to start I had to run the first cell. I appears to be an error with that. I am new with github. I would be happy if you could help me :) Below, I sent the screenshot
duv1

@SebastianoF
Copy link
Contributor

SebastianoF commented Dec 26, 2021

Hello,
As specified in the readme you should run the commands with a python interpreter with the libraries/packages under requrements.txt installed.

You can achieve this in multiple ways (as there are multiple package managers, and your computer is likely to have multiple interpreters installed already, at OS level).

The "standard" way is with virutalenvironments, which are environments that you can activate and deactivate at will. They run in parallel to the python interpreter installed systemwide, and they enable you to keep the interpreter you use for the exercises (or any project) separate from the system environment.

The reason why environments are so handy is that you may have different projects with different requirements not compatible between each others, and you may want to have the freedom of messing up with the environment without risks for the rest of the system. E.g.

  • imagine project1 requires numpy version 1.12, and project2 requires numpy version 1.17, then each time you have to change project you will need to uninstall and re-install the correct version.
  • imagine you are experimenting with a new library that you are developing. You may not want to pollute the python interpreter your operative system is using to make everything works with a possibly buggy library.

To create a virualenvironment for just this project you have to:

  1. install virualenv (this depends entirely on your operative system, it can be as simple as pip3 install virtualenv or it can be longer, depending on your system. Please google this one for more details about your system).
  2. use the virtualenv command line to create a new environment called venv and using the interpreter python3.7 with: virtualenv venv -p python3.7 (python3.7 must be available installed as well on your computer, if you do not have it, you can install following the official python website. You can also chose another version. Anything above 3.5 would work).
  3. activate the environment with the bash command source venv/bin/activate (bash will tell you that you are in the environment now, with (venv) on your shell prompt).
  4. from the folder you just cloned, install the libraries with pip install -r requirements.txt. If you are curious you can see the difference between pip outside the virtualenv and inside the virtualenv with which pip before and after activating the environment.
  5. Now all the libraries you need to run the code are installed in the right interpreter. You can start the Jupiter notebook, and tell to the notebook that it has to use the interpreter under the venv folder. (this depends on the notebook, if you use Jupiter, Jupiter lab, vscode integrated notebooks, pycharm integrated notebooks...). On your screenshot click top right where you find "3.8.12 Python". This would open a drop down menu where you can chose the version.
  6. Once you are done doing a bunch of exercises, you can deactivate the virtualenvironment from where you start the notebook, simply typing deactivate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants