Python Virtualenv showing computer libs

Asked

Viewed 47 times

-2

good night. (I use Ubuntu) I’m dealing with flask with some colleagues and we use Virtualenv to create virtual environments. My problem is this: Whenever I pull something from github and already comes the virtual environment folder, when I try to run it says that the libs that we import into the files do not exist. However, I’ve already checked and they’re inside the briefcase. When I enter the virtual environment I pulled the terminal and give the command pip3 Freeze, it shows the same libraries q when I give the command outside the virtual environment. The virtual environment only works as expected when I create and install the libs myself. I’m suspecting it’s because I use linux and the other members of the project use windows, does it interfere with anything? I couldn’t find anything about it. Thank you for your attention.

1 answer

2

Good - the main problem is that virtualenv never should be bundled with the other versioned files in GIT. What needs to be in git is the file that lists the dependencies - in general the Resetters.txt (but there are other file types that have the same role, the most modern being the "Pipfile" of the "pyenv" project, but also "buildout", or the "setup.py" itself can contain all the dependencies).

Among the problems of trying to read the virtualenv library itself, one of the big ones (but never the only one), is that any library that has a file compiled in native code (that is, that it is not pure Python), is not, once installed, "multi-operating system"- that is, if they installed, for example, the lib "lxml" in Windows, its files in virtualenv are not compatible with Linux.

This has nothing to do with the problem you are reporting - but there may be more differences between a virtualenv created in windows, and others on normal operating systems. (When it comes to development environment, Windows is "the ugly duckling", which uses different rules from around the world - Linux, Bsds, Macos, all Unix systems, which are used in cloud, mobile, embedded, etc...). In particular, a virtualenv in general is fixed in the absolute directory in which it was created - try to move it does not work well - and where it will stay in Linux will forcibly have a different name than the paths used in Windows (the path will not start with "C:", for example)

So - you don’t tell how you are "activating" this virtualenv, but the chance is that it is not active "at all". And if it were, some of the libraries wouldn’t work, because of the binary incompatibility.

solution:

Remove the contents of virtualenv from the GIT repository, create a.txt file, and each developer creates their virtualenv on your machine - adjusted to the system you’re working on, and the present directory structure.

  • An extra, developers can agree to use the same directory name to store the virtual environment ("py3", "venv", etc.) and place this subject within the ". gitignore" so this never happens again.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.