Reputation: 1212
I am trying to install PyJWT package into an environment, but running into an issue where it seems to have installed, and I can import the package in python, but the package is empty.
I do the following from a Windows command line:
activate my-env
and I see my command prompt reflect the change by showing (my-env) then I issue
pip -install PyJwt
and that says successful. So now I run python and try
import jwt
dir(jwt)
The import works, but dir()
gives the following output:
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
HOWEVER, if I do not first select the environment, i.e. I do a pip install
without first activating an environment, then the install works correctly and when I run dir
on the package I see the right output:
['DecodeError', 'ExpiredSignature', 'ExpiredSignatureError', 'ImmatureSignatureError', 'InvalidAlgorithmError', 'InvalidAudience', 'InvalidAudienceError', 'InvalidIssuedAtError', 'InvalidIssuer', 'InvalidIssuerError', 'InvalidSignatureError', 'InvalidTokenError', 'MissingRequiredClaimError', 'PyJWS', 'PyJWT', 'PyJWTError', '__author__', '__builtins__', '__cached__', '__copyright__', '__doc__', '__file__', '__license__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__title__', '__version__', 'algorithms', 'api_jws', 'api_jwt', 'compat', 'decode', 'encode', 'exceptions', 'get_unverified_header', 'register_algorithm', 'unregister_algorithm', 'utils']
The issue of course is the package now isn't available in the environment in which I want to use it.
Any suggestions on what I've done to create this situation?
Upvotes: 0
Views: 1641
Reputation: 1
Try this:
Before installation you need to remove the package by using the below command:
apt-get remove python3-jwt
In this case, the installer will install the package using the below command:
pip3 install pyjwt
Upvotes: 0
Reputation: 3675
Did you actually try to use the package and got an error, or are you just looking at the output of dir(...)
and think that something's wrong? Maybe the Python version in your conda environment uses lazy loading, while the Python version outside of conda does not.
Since you're using Anaconda, consider to install PyJWT with conda
instead of pip
into your environment. This should resolve all dependencies automatically:
conda activate my-env
conda install pyjwt
Upvotes: 1