Errors Using Pipenv When Installing Numpy Versions in Virtual Environment

Receive this error when following the lesson to use pipenv to create local instances of python and dependencies:

It seems I had no trouble installing various versions of the “requests” package, but numpy will only successfully install the very latest version. Otherwise, I receive the error.

I’ve noticed the CodeAcademy instruction video is a bit old, i.e. using --three to create a virtual environment is deprecated, so perhaps there is new information in the setup I’m missing? My Python version is 3.11.1, on a Windows 10 machine. I’m using Visual Studio Code.

Any ideas?

I’ve noticed the CodeAcademy instruction video is a bit old, i.e. using --three to create a virtual environment is deprecated, so perhaps there is new information in the setup I’m missing?

Hi There,

Hope you are doing well. Yes, you are correct, CodeAcademy instruction video is a bit old; however, using -- has not depreciated. According to the pipenv doc, the command to install pipenv is:

pip install --user pipenv

I use pipenv daily, I might be able to assist you with this. Follow these steps in creating a new virtual environment using pipenv.

Step 1: Make project folder

mkdir my_project

Step 2: Change Directory

cd my_project

Step 3: Install Packages

pipenv install <package_name>

Step 4: Activate Virtual Environment

pipenv shell

This will spawn a new shell subprocess, which can be deactivated by using exit.

If the instructions tell you to install a specific older version of numpy that is causing an error then I would go with that latest version. Let me know if this helps or if you need further assistance!

1 Like

Hi Seraph!

I appreciate you taking the time to reply. I hope you are well, too!

It is no problem to just install numpy at its latest version.

I suppose my primary concern is that if I can only use the latest versions of a package in a virtual environment, that would limit my capability to perform tasks. So far I can’t find good guidance on that, or if I should even be concerned about it. Why use a virtual environment at all if it just matches my global environment?

Your clear outline of the steps are great! They are more complete than the lesson, in fact, and affirm some of the features I’d discovered on my own. At this stage I can continue the main flow of my coursework.

I would still be interested in any clarification on what causes issues with installs due to not being able to “build wheels”, or if there are work arounds, if you or others know the answer, or where to look for one.

But regardless, your help has been helpful!. Thank you.

I suppose my primary concern is that if I can only use the latest versions of a package in a virtual environment, that would limit my capability to perform tasks … Why use a virtual environment at all if it just matches my global environment?

Why use Virtual Environments

Using virtual environment isolates Python installs and associated pip packages. For example, let’s say you had Python 3.11 on your machine, and you wanted to run another program from a GitHub repo that was developed in Python 2, and you didn’t want to to install Python 2 on your local machine. Then you would create a virtual environments.

Virtual environments also allows the end-user to install and manage their own set of dependencies not provided on their system. For example, let’s say you developed a program with x, y, x package requirements. If I didn’t have x, y, z packages installed in my local machine then I couldn’t run your application. Therefore, to run your application on my machine I would utilize a Virtual Environment, so I do not have to permanently install x, y , z in my local machine. Does that make sense?

Specify Versions of a Package

I also want to mention that you can install any version of a package that you desire. That is the beauty of virtual environments. To install a specif version of a package, you use the Semantic Versioning scheme (i.e. major.minor.micro). For example:

pipenv install django~=2.2

Pipenv will install version 2.2 and any minor update, but not 4.1.
Additionally, you can choice a specific version of Python using the --python VERSION flag, like so:

Use Python 3:

pipenv --python 3

Use Python 2.7.14:

pipenv --python 2.7.14

I would still be interested in any clarification on what causes issues with installs due to not being able to “build wheels”, or if there are work arounds,

Hey, now that I think about it, I had a similar issue with Matplotlib when Python 3.10 first came out! You said you had Python 3.11 on your machine, correct?! Well, It was just released 10242022. Your problem could be some dependencies haven’t been ported yet!!

Possible Solutions

Try one of these possible solutions and see if it resolves your issue:

Option # 1

Uninstall Python 3.11 completely off your machine. Go back to 3.10, and then try your numpy install with Python 3.10

Option # 2

Create a Virtual Environment using Python 3.10, and then install numpy!

pipenv --python 3.10
pipenv insatll numpy

Let me know if any of these solutions worked for you. If they don’t, then just give it some time. Again since Python 3.11 was just released a few days ago, some dependencies haven’t been ported over, and this could the reason for the error. If you have any more questions regarding this topic, please feel free to ask!

Seraph! You are an angel, indeed! You helped me find the solution.

I was confused because originally I had Python 3.10.9 and had the same problem, but ended up updating to Python 3.11. When I tried your suggestion to run a virtual environment with 3.10.0, then the numpy versions I’d failed to install before installed just fine. I guess 3.10.9 was also just too new.

So some version incompatibility was at issue, but I went in the wrong direction with my updates.

To be clear, the solution I used from your suggestions (which worked) was:

pipenv --python 3.10
pipenv install numpy==1.22.4

At this stage I have no more questions, and won’t need any more help. I really appreciate it! :slightly_smiling_face:

Cheers!

1 Like