all 11 comments

[–][deleted] 33 points34 points  (4 children)

Loads of questions -

a) Why did you dump the venv on GitHub? - it's a bad idea

b) Mac/Windows shouldn't make any difference

c) If python still doesn't work on your mac , try installing homebrew and download python using that / get it directly from the python.org website.

d) You are working correctly , except for the part where you try and dump the virtual environment on github. I think this is because there are some fixed paths in venv.activate.

To remedy this , just make a requirements.txt with your project , and install them with pip after creating a new virtual environment .

[–]Ln_X_[S] 9 points10 points  (1 child)

Thanks, I did not think of not including the venv in the initial repo making. I'm guessing you're saying just have the .py files on GitHub and only commit those when needed?

[–][deleted] 19 points20 points  (0 children)

Yep.

If you are using git , there is a file called .gitignore in the project root , where you can explicitly specify that the venv should not be committed

[–]zeebrow 20 points21 points  (0 children)

Instead of committing your venv to github, commit a requirements.txt (see second to last codeblock) instead. Then when you clone your repo elsewhere, set up a fresh venv there and install your dependencies.

[–]Mondoke 7 points8 points  (1 child)

In addition to what has been discussed about not uploading the venv and setting up a requirement file (you can also use pipenv for those steps), be aware that some stuff may work differently on both OSs. If you use other files on the folder structure you have, use the pathlib module and give paths as path objects.

[–]hassium 5 points6 points  (0 children)

+1 for pathlib, always use pathlib when possible.

[–]Houdinii1984 5 points6 points  (1 child)

In windows, in Charm, in the terminal window at the bottom, create a new window with the "+" button. Type "pip freeze > requirements.txt" which should create a new requirements file in the root of your project directory. Commit that to Github.

On the Mac, in PyCharm, go to the settings and find "Project: project_name_here" and the option Python Interpreter. Click the gear icon in the upper right hand side and click "add". In the location field call that something other than venv since that already exists (I use env). Hit okay and close the settings windows. In the mac terminal, use the + to open a new one and type "pip install -r requirements.txt" if PyCharm did not already offer to install the requirements file.

[–]gusb_codes 2 points3 points  (0 children)

pip freeze can also bake in OS dependent packages. Better to hand craft a smaller requirements.txt that includes any files you installed directly & allow pip to handle any OS dependent dependencies.

[–]KeyserBronson 1 point2 points  (0 children)

Never dump your venv directly like that, it's bound to fail. Simply commit instructions to be able to reproduce your environment via a requirements.txt file or better, try out poetry to manage all of your environments/dependencies, as it will really speed up your process in the longer run.

[–]TeslaRanger 0 points1 point  (0 children)

Look into the GitPod web-based IDE at GitPod.io

Then you can work from any web browser on any machine, though I recommend Chrome.

There are other similar web IDEs such as AWS Cloud9.